array( 'user_name' => $user_name, 'password' => md5($user_password), ), ); $json = json_encode($parameters); $postArgs = 'method=login&input_type=JSON&response_type=JSON&rest_data=' . $json; curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs); // Make the REST call, returning the result $response = curl_exec($curl); // Make the REST call, returning the result $response = curl_exec($curl); if (!$response) { die("Connection Failure.\n"); } // Convert the result from JSON format to a PHP array $result = json_decode($response); if ( !is_object($result) ) { die("Error handling result.\n"); } if ( !isset($result->id) ) { die("Error: {$result->name} - {$result->description}\n."); } // Get the session id $sessionId = $result->id; echo "Login Successful! Session ID is {$sessionId}\n"; // Retieve the contact record we just created $parameters = array( 'session' => $sessionId, 'module_name' => 'Contacts', 'query' => "", 'order_by' => 'last_name', 'offset' => '', 'select_fields' => array('id','name','full_name','last_name','first_name','email1','primary_address_street','primary_address_city', 'primary_address_state', 'primary_address_postalcode', 'primary_address_country'), 'link_name_to_fields_array' => array()); $json = json_encode($parameters); $postArgs = 'method=get_entry_list&input_type=JSON&response_type=JSON&rest_data=' . $json; curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs); // Make the REST call, returning the result $response = curl_exec($curl); if (!$response) { die("Connection Failure.\n"); } // Convert the result from JSON format to a PHP array $result = json_decode($response); if ( !is_object($result) ) { die("Error handling result.\n"); } if ( !isset($result->result_count) ) { die("Error: {$result->name} - {$result->description}\n."); } var_dump($result);