我想在codeigniter中调用API。我收到了HTTP请求错误,请指导我。
遇到PHP错误 严重性:警告
Message: file_get_contents(http:/.@kk.com&password=kk&devicemedium=WEB): failed to open stream: HTTP request failed! HTTP/1.1 405 Method Not Allowed
Filename: controllers/search.php
Line Number: 602
答案 0 :(得分:1)
我看到一个格式错误的网址!
的file_get_contents(HTTP:/.@ kk.com&安培;密码= KK&安培; devicemedium = WEB)
"http:/.@kk.com"
你打电话给好网址了吗?
卷曲优于file_get_contents
(参见:http://bitly.com/1zrYkDN)
试试这个,不要忘记激活php.ini中的CURL扩展
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://new.ezeeinfosolutions.com/busservices/auth/getAuthToken?namespaceCode=demo&username=' . $username . '&password=' . $password . '&devicemedium=' . $medium,
CURLOPT_USERAGENT => 'cURL Request'
));
$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);