Reputation: 73
Below is the code I have written. But its not showing anything on my screen. Am I missing anything?
error_reporting(E_ALL);
ini_set("display_errors", 1);
$reservation_obj['source'] = "website";
$reservation_obj['location_code'] = "test";
$reservation_obj['start_date'] = "2010-06-01 19:00";
$reservation_obj['end_date'] = "2010-06-04 13:50";
$reservation_obj['action'] = "get_quotes";
$json = json_encode($reservation_obj);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"https://myserver/test.php");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch,CURLOPT_HTTPHEADER, array('Content-Type: text/json', 'Content-length: '.strlen($json)));
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $json);
curl_setopt($ch,CURLOPT_VERBOSE, false);
curl_setopt($ch,CURLOPT_SSLCERT,getcwd()."key/test_services.pem");
curl_setopt($ch,CURLOPT_SSLCERTTYPE, "PEM");
curl_setopt($ch,CURLOPT_SSLKEY,getcwd()."key/test_services.p12");
curl_setopt($ch,CURLOPT_SSLKEYTYPE, "P12");
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_SSLVERSION, 3);
$output=curl_exec($ch);
curl_close($ch);
print_r($output);
This is what I got on printing
echo "<pre>";
var_dump(curl_getinfo($ch));
echo "</pre>";
Below is the output I got. And I server need the ssl certificate thats why I added the ssl things. If am wrong please help me.
array(26) {
["url"]=>
string(68) "https://myserver/test.php"
["content_type"]=>
NULL
["http_code"]=>
int(0)
["header_size"]=>
int(0)
["request_size"]=>
int(0)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(0.325151)
["namelookup_time"]=>
float(0.124679)
["connect_time"]=>
float(0.400445)
["pretransfer_time"]=>
float(0)
["size_upload"]=>
float(0)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(-1)
["upload_content_length"]=>
float(-1)
["starttransfer_time"]=>
float(0)
["redirect_time"]=>
float(0)
["redirect_url"]=>
string(0) ""
["primary_ip"]=>
string(14) "204.13.111.172"
["certinfo"]=>
array(0) {
}
["primary_port"]=>
int(443)
["local_ip"]=>
string(12) "192.168.1.75"
["local_port"]=>
int(36492)
}
After removing it I got this:
rray(26) {
["url"]=>
string(68) "https://wsh.netpark.us/reservation_services/test/ws_reservations.php"
["content_type"]=>
NULL
["http_code"]=>
int(0)
["header_size"]=>
int(0)
["request_size"]=>
int(269)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(2.50114)
["namelookup_time"]=>
float(0.124669)
["connect_time"]=>
float(0.51286)
["pretransfer_time"]=>
float(1.316726)
["size_upload"]=>
float(124)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(49)
["download_content_length"]=>
float(-1)
["upload_content_length"]=>
float(124)
["starttransfer_time"]=>
float(0)
["redirect_time"]=>
float(0)
["redirect_url"]=>
string(0) ""
["primary_ip"]=>
string(14) "204.13.111.172"
["certinfo"]=>
array(0) {
}
["primary_port"]=>
int(443)
["local_ip"]=>
string(12) "192.168.1.75"
["local_port"]=>
int(36695)
}
Upvotes: 4
Views: 5896
Reputation: 359
Try this after you curl_exec command and before curl_close. That should print any errors.
if($errno = curl_errno($ch)) {
$error_message = curl_strerror($errno);
echo "cURL error ({$errno}):\n {$error_message}";
}
Upvotes: 8