$url="http://182.191.78.79:92/api/ERP/Login?UserName=xxx&Password=xxx&LocationId=";
$secretKey = "sk_test_1234567";
// append the header putting the secret key and hash
$request_headers = array();
// $request_headers[] = 'Authorization: Bearer ' . $secretKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
// curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
if (curl_errno($ch))
{
print "Error: " . curl_error($ch);
}
else
{
// Show me the result
$transaction = json_decode($data, TRUE);
curl_close($ch);
var_dump($transaction);
}
Asked
Active
Viewed 688 times
0

fire
- 21,383
- 17
- 79
- 114

Waleed Ali
- 21
- 1
- 5
-
format your code and give a detailed description, please. – Jose Rojas Jan 09 '18 at 14:25
-
My most favorite troubleshooting question: What happens when you try? Do you receive any error messages? – aynber Jan 09 '18 at 14:28
-
Not working how? Error messages? Wrong result? Does the computer crash? Please read: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) and also [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) – M. Eriksson Jan 09 '18 at 14:42
-
Turn on error reporting and execute the script. Then you may able to see PHP errors if there are any exceptions. Sometimes this may be a problem caused by your firewall. – srimaln91 Jan 09 '18 at 15:25
-
Error: Failed to connect to 182.191.78.79 port 92: Connection refused – Waleed Ali Jan 10 '18 at 06:21
-
I found this error – Waleed Ali Jan 10 '18 at 06:21
1 Answers
1
Did you check if curl is available in PHP on your server?
function _isCurl(){
return function_exists('curl_version');
}
Source: https://stackoverflow.com/a/13433965/4934937
If your server is running php5 and using linux, you can try to install the package php5-curl, since it's not installed by default.

maio290
- 6,440
- 1
- 21
- 38
-
-
What does it mean same code is working on local Apache Server but not working on live domain. – Waleed Ali Jan 10 '18 at 06:42
-
according to your comment "Connection refused" - this seems to be a whitelist related error, so you may whitelist your live server's IP address. – maio290 Jan 10 '18 at 09:52