我想打电话给在纯PHP的API,但是当我使用的file_get_contents,卷曲,get_header,我有我的Web服务器everithing启用检查。(OpenSSL的,延长= php_openssl.dll)HTML的API调用状态405
我想知道为什么这不运行?
使用的file_get_contents
<?php
$username = '[email protected]';
$password = 'newnew';
$medium = 'WEB';
$json = file_get_contents("http://new.ezeeinfosolutions.com/busservices/auth/getAuthToken?namespaceCode=demo&[email protected]&password=newnew&devicemedium=WEB");
$array = json_decode($json, true);
echo $array;
echo $array['status']; // status
echo $array['datetime']; // date time
echo $array['data']['authToken']; // auth token
echo $array['data']['role']['code']; // code
?>
输出: 的file_get_contents(http://new.ezeeinfosolutions.com/busservices/auth/getAuthToken?namespaceCode=demo&username=ram%40demo.com&password=newnew&devicemedium=WEB):未能打开流:HTTP请求失败! HTTP/1.1 405方法不使用crul在/home/vkacadem/public_html/api/index.php允许第5行
:
$ch = curl_init("http://new.ezeeinfosolutions.com/busservices/auth/getAuthToken?namespaceCode=demo&username=$username&password=$password&devicemedium=$medium");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
**0/p: no response?**
我的API是通过GET方法等待呼叫。
您正在使用HTTP。你为什么要检查openssl? – 2014-10-27 10:10:37
如果不介意,你可以告诉我你什么时候使用openssl只是为了这个任务,我搜索了谷歌的一切。我总是保证stackteam – 2014-10-27 10:38:01