David
David

Reputation: 237

What are these php Curl response headers indicative of?

I am trying to use Curl to communicate with the API of a server:

  $ch = curl_init(); 
  curl_setopt($ch, CURLOPT_URL, 'pilot-payflowpro.paypal.com');
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
  curl_setopt($ch, CURLOPT_HEADER, 1); // tells curl to include headers in response
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
  curl_setopt($ch, CURLOPT_TIMEOUT, 45); // times out after 45 secs
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // this line makes it work under https
  curl_setopt($ch, CURLOPT_POSTFIELDS, $plist); //adding POST data
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2); //verifies ssl certificate
  curl_setopt($ch, CURLOPT_FORBID_REUSE, TRUE); //forces closure of connection when done 
  curl_setopt($ch, CURLOPT_POST, 1); //data sent as POST 

  $result = curl_exec($ch);
  $headers = curl_getinfo($ch);
  print_r($headers);

However, the $result variable is empty, which as returntransfer was set to 1, means that no response was given. Printing out the headers gives:

( [url] => HTTP://pilot-payflowpro.paypal.com [content_type] => [http_code] => 0 
[header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 
[redirect_count] => 0 [total_time] => 1.656 [namelookup_time] => 0.062 [connect_time] => 0
 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 
[speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 
[starttransfer_time] => 0 [redirect_time] => 0 [certinfo] => Array ( ) ) 

What does this suggest in terms of debugging? I am using wamp on my local desktop with curl enabled.

Thanks.

Upvotes: 0

Views: 678

Answers (1)

Manu Eidenberger
Manu Eidenberger

Reputation: 2096

Seems like you CURLOPT_URL param is wrong... try it with a fully filled url (http://pilot-payflowpro.paypal.com)

In your example, curl doesn't know which protocol to use (http, https)

Edit : Try it with https://pilot-payflowpro.paypal.com since the server you mention doesn't respond on the http protocol

Upvotes: 1

Related Questions