I am having a problem Here
<?php
include('smsconfig.php');
include("SMTPconfig.php");
include("dbconnect.php");
define("SITE_URL", "http://gf2fyu.blah.com");
$GLOBAL_REST_URL = "gf2fyu.domain.com/organization/";
$headers = array(
'X-MYDOMAIN-Secret:VuFlRQv40SUp0y1AXflMD0hWw8ZiiTu08f9ZXc0AYFc=',
'Content-Type: application/json; charset=UTF-8',
'Accept: application/json; charset=UTF-8',
);
//$json = array2json($ages);
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,$GLOBAL_REST_URL);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
// curl_setopt($curl_handle, CURLOPT_POSTFIELDS,$json);
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
$getit = json_decode($buffer, true);
$smskey = substr(number_format(time() * rand(),0,'',''),0,5);
print_r($getit);
?>
The above code working fine for me if i am running it on my local server and mozila REST
client but whenever i am trying to put this code on production version
this code is not hitting the rest server .
Please tell me what is the problem here ?
I am using the same header in MOzila also it is working fine
I am running Nginx
Everything really is in the comments, but let’s put it down in order.
1) Curl may not be installed in the PHP on the server. To find out, turn on error reporting (or check error logs). Alternatively, a more robust way is to check for the function. Add the following to your code (just after the includes)
Solution: you can try file_get_contents, but as noted in comments is it generally not recommended because this is also disabled. If you need to pass headers, you can do this in the “context” (third parameter in the call – check the manual). Better option is to install curl (or get support to install it).
2) There may be a firewall enabled. You can establish this by checking curl_getinfo() and dumping the result to screen (for testing). This will tell you if it got blocked or made it through. See the manual for more info (linked above).
3) There may be an error higher up in your code that is causing problems. Check the error log, or turn on error_reporting with
Remember to remove those lines when you finally go into production, though.