I am using the sample code of paypal in php from
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/library_code
but whenever i am running this sample code i am getting this error.
"DoDirectPayment failed: couldn't connect to host(7)"
I have no clue what's the problem.
Note: I am using local WAMP server for running this sample.
// Set the curl parameters.
- $ch = curl_init();
curl_setopt($ch, CURLOPT_PROXY, " http://username:password#proxyserver.net:port/";);
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1); // Turn off the server and peer //verification(TrustManager Concept).
curl_setopt($ch,
CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch,
CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch,
CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
//The rest of the code from paypal site
Related
I am stuck here:
I get this Error: TCP connection reset by peer.
This is my CURL Script
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_webpay);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_TIMEOUT, 60);
//curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
//curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POST, false );
Without the comments, I get the error message.
Just leaving those options readable in the code above displays the page without the error but does not give me access to the $header.
I have done this:
curl_setopt($ch, CURLOPT_CAINFO, "/abc/ssl/certs/abc.crt");
I get a different error.
Can someone guide me on what am missing? I am using php 5.4.16 on CentOS 7.
I want to get all the CURL options working, cos I need to get feedback from the headers.
little piece of code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://image.example.jpg');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$c = curl_exec($ch);
this works from a server but wont work from another. curl_errno() returns false with error 7 - couldn't connect to host, and curl_error() say "failed to connect to %%%%%% port 80: connection timeout". But it only applies to a specific server! If I put an other image from google, it does work from both server! What can it be?
I am sending request by cURL to server by following code, and it is giving permission error as "Apache/2.4.16 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 Server".
the cURL code is...
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $my_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "key=".$my_key);
curl_setopt($ch,CURLOPT_REFERER, site_url());
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$res = curl_exec($ch);
curl_close($ch);
return $res;
anybody please guide me what is error, or what should I do to resolve issue.
thanks a lot.
The error seems to be related to SSL i.e. https request. You can ignore verification by adding below lines:
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
Code:
$url = 'example/'.$reqID.'/';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
//var_dump($output);
curl_close($ch);
Error:
curl_setopt() [function.curl-setopt]: Invalid curl configuration option
the error can indicate that you try to use curl in an IPv6 enabled environment and don't tell curl to resolve over IPv4
try to set the option
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
Allows an application to select what kind of IP addresses to use when
resolving host names. This is only interesting when using host names
that resolve addresses using more than one version of IP, possible
values are CURL_IPRESOLVE_WHATEVER, CURL_IPRESOLVE_V4,
CURL_IPRESOLVE_V6, by default CURL_IPRESOLVE_WHATEVER.
This is regarding paypal through Curl. I am trying to access paypal by using below code. The code is working fine in one server. After moving this code to live server, getting the below error. Can anybody tell me the solution for this.
$API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
$version = urlencode('76.0');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
// Turn off the server and peer verification (TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
// Set the API operation, version, and API signature in the request.
$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
// Set the request as a POST FIELD for curl.
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
// Get response from the server.
$httpResponse = curl_exec($ch);
Error:
SetExpressCheckout failed: Unknown SSL protocol error in connection to api-3t.sandbox.paypal.com:443 (35)
Can you set curl_setopt($ch, CURLOPT_SSLVERSION, 3);?
curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
I inserted this line in my code
Did you try this alternative ?