Issue with Neteller API REST API - php

I have an issue trying to implement Neteller's REST API. I have created my app in the merchant account (I don't have an SSL certificate in my site), I have a static IP for my web site and it is added to Neteller's allowed IP list, but for some reason I always receive a null response back from them.
This is my code:
$username = 'XXXXXXXXXXXXXXXX';
$password = 'XXxxxxxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, "https://api.neteller.com/v1/oauth2/token?grant_type=client_credentials");
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type:application/json", "Cache-Control:no-cache"));
curl_setopt($curl, CURLOPT_POSTFIELDS, array("scope"=>"default"));
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$serverOutput = curl_exec($curl);
$info = curl_getinfo($curl);
echo $serverOutput; // null response
Can anyone help me to solve this issue?

If you are receiving a null response to the curl_exec() method, this could indicate a problem establishing the HTTP connection.
try adding:
print_r(curl_errno($curl));
This will return the curl error code, which you can then check against this list.
Most probably it is a problem establishing the SSL connection - because the certificate issuing authority is not trusted by your cUrl installation. You can fix this by updating the trusted certificate authorities list. More info here.

Related

can't able to curl google even after using proxy

I'm trying to scrape data from google results and for this doing curl request which works fine for few searches but after that it starts showing "Our systems have detected unusual traffic from your" then tried using proxy but still getting the same however; the ip is now changed after uisng proxy but not the error.
Error Image
Here is the code i'm using;
$curl=curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_PROXY, 'ip');
curl_setopt($curl, CURLOPT_PROXYPORT, 'port');
curl_setopt($curl, CURLOPT_PROXYUSERPWD,'user:pass');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
if($result === FALSE) {
die(curl_error($curl));
}
curl_close($curl);

CURL function returns Erron Number: 56 Error String:Received HTTP code 406 from proxy after CONNECT

The purpose of this CURL is to generate a token for the user. If the token is returned correctly, then the user can be able to access all the menus. If not, the user will get a logout from the application.
$ch = curl_init();'
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PROXY, 'Proxy IP');
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$result = curl_exec($ch);
What I am missing here??
NOTE: The server I am connecting to is in the AWS cloud, and we already have a server which is outside the cloud, and the curl is working fine and the generated token is receiving. I am not sure what the problem here is.

Paypal Curl redirecting Issue

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 ?

CURL invoking API with SSL

I am using CURL to invoke an API with self signed public key in .pfx extension
function execute_curl($string,$URL)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml','SOAPAction:"http://xxxxxxxxxxxxxxxxxx/SendDoc"'));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
$ch_result = curl_exec($ch);
return $ch_result;
}
I cannot set the CURLOPT_SSL_VERIFYPEER to FALSE for security purpose, anyone can show me how I can properly add the certificate along with its password into curl? EDIT I am not even sure if that is the solution for it, so far I am only getting no response from it. Any additional solution or ways to make it work is very much appreciated.
Also, I am trying to make it work on 2 environment, my dev environment which is in windows and also my test server environment which is in fedora, should the certificate be in different format?

unable to execute an url through curl

I am unable to execute an URL through curl. But if simply run the query thrugh browser, its working fine. My code is like:
$xmlData = "<Leads><row no='1'><FL val='First Name'>".$new_fname."</FL><FL val='Last Name'>".$new_lname."</FL><FL val='Email'>".$new_email."</FL><FL val='Phone'>".$new_ph_no."</FL></row></Leads>";
$xmlData = htmlentities($xmlData);
$ch = curl_init("https://crm.zoho.com/crm/private/xml/Leads/insertRecords?newFormat=1&authtoken=XXX&scope=crmapi&xmlData=".$xmlData);
curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);// Turn off the server and peer verification
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'rsa_rc4_128_sha'); //for godaddy server patch
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//Set to return data to string ($response)
curl_setopt($ch, CURLOPT_POST, 1);//Regular post
$response = curl_exec($ch);
curl_close($ch);
could you please let me know where is the issue?
Thanks in advance.
The following code should work:
$ch = curl_init("https://crm.zoho.com/crm/private/xml/Leads/insertRecords?newFormat=1&authtoken=XXX&scope=crmapi&xmlData=".$xmlData);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// deactivate certificate checking
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//Set to return data to string ($response)
curl_setopt($ch, CURLOPT_POST, 1);//Regular post
$response = curl_exec($ch);
if(!$response) {
echo curl_error($ch), PHP_EOL;
}
curl_close($ch);
After discussion comments I realized that the problem is, that you haven't installed the Thawte ssl certificate on your system. You have two options:
Install the certificates
Disable certificate checking using CURLOPT_VERIFYPEER = FALSE
I've used the second approach in my example just to show how to make your code working. For a production system I would advice you to install the certificates.

Categories