acer s
acer s

Reputation: 1

I want to call API in codeigniter. I got a HTTP request error kindly guide me

I want to call API in codeigniter. I got a HTTP request error kindly guide me.

A PHP Error was encountered Severity: Warning

Message: file_get_contents(http:/[email protected]&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

Upvotes: 0

Views: 494

Answers (1)

Bouhnosaure
Bouhnosaure

Reputation: 78

I see a malformed url !

file_get_contents(http:/[email protected]&password=kk&devicemedium=WEB)

"http:/[email protected]"

Did you call the good url ?

Curl is better than file_get_contents (see : http://bitly.com/1zrYkDN) Try this and don't forget to activate the CURL extention in your php.ini

$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);

Upvotes: 1

Related Questions