0

I am trying to run .php scripts on windows machine. I first tried older version of php which was php 5.4.6 and enabled php_curl on php.ini(found in php folder) and after running my script using cmd(c:\php\php.exe test.php) (i got this error:

php startup:unable to load dynamic library c:php\php_curl.dll' - The specified module could not be found

so i renamed c:/php to c:/phpOld/ and created another folder (c:/php) unzipped the newer version of php files in to it(php-5.6.17-nts-Win32-VC11-x86.zip). I found two php.ini files on same folder as php files called php.ini-development and php.ini-production . I enabled php_curl on both of those files(changed ;extension=php_curl.dll to extension=php_curl.dll) and after running the script i still get this error:

Fatal error: Call to undefined function curl_init() in

I went and checked ext folder and I saw php_curl.dll file is there! could any one tell me why php curl is not running and I get the above error ?Thanks in advance.

Edit: this script runs correctly on webserver but gives empty result when running it locally! Is there any limitation on making curl post request this way ?

$data = array(
    'a'      => 'test1',
    'b'    => 'test2',

);


$url = "https://api.somewebsite.com/auth.aspx";    
$content = json_encode($data);

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
        array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$json_response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

curl_close($curl);

$response = json_decode($json_response, true);
echo "full Response:".$json_response;
user1788736
  • 2,727
  • 20
  • 66
  • 110
  • 1
    Those php.ini files you listed don't get used, they are only examples. You need to rename one of them to just php.ini, that will be your main file. – Rainner Feb 04 '16 at 00:49
  • Thanks . That fixed the php curl issue. But now i get problem making php json curl post request. Same script runs correctly on webserver but gives empty result running it locally? Is there any limitation for making json curl post request locally ? array("Content-type: application/json")); curl_setopt($curl, CURLOPT_POST, true); – user1788736 Feb 04 '16 at 01:10

0 Answers0