I want to call API in plain php but when I use file_get_contents, curl, get_header,
Use file_get_contents
Output: file_get_contents (): Failed to open stream: HTTP request failed! The HTTP / 1.1 405 method is not allowed on /home/vkacadem/public_html/api/index.php line 5.
Use crul:
$ ch = curl_init ("http://new.ezeeinfosolutions.com/busservices/auth/getAuthToken? NamespaceCode = demo & amp; username = $ username & ampword = $ password & devicemedium = $ medium;); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, true); Curl_setopt ($ CH, CURLOPT_HEADER, 0); $ Data = curl_xac ($ ch); Curl_close ($ ch); $ Data echo; ** 0 / P: No response? **
My API is waiting for a call through the GET method.
You have to post data. Add
curl_setopt ($ ch, CURLOPT_POST);
Before sending a request
Tip: If you are using Chrome, then install Postman Extensions. You will be allowed to debug such problems easily
Comments
Post a Comment