Php and connecting to an API -
This can be a very basic question because I am quite new to PHP programming. I hope I can learn something about my special issue.
I am trying to create a simple web application that will be working with PHP which will interface with the BBYOpen API provided by Best Buy.
Now provides the query for BBYOpen developers, which I have managed to find one to use.
My problem is new to PHP, this is:
-
How can I create a simple HTML page that will accept user input, a zipcode and Distance form) and tie in the php script that can communicate with BBYOpen to retrieve the data.
-
Provides extensive documentation for the BBYOpen query and the information I can make is a viable return, but how to get my PHP script to connect to BBi Open I know that I need to use my remix web service to connect, but I also tell how to go about doing this.
The solution will also be appreciated in a general code with any help or comments.
Cheers
$ ch = curl_init ('http: // Api.remix.bestbuy.com/v1/products?apiKey=apiKey&format=json '); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, true); Curl_setopt ($ CH, CURLOPT_HEADER, true); Curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ('content-type: application / jason',)); $ Result = curl_xac ($ CH); $ Header_size = curl_getinfo ($ ch, CURLINFO_HEADER_SIZE); $ header = substr ($ result, 0, header_ size); $ body = substr ($ result, $ header_size); Curl_close ($ ch); Echo "& lt; east & gt;"; Print_r (json_decode ($ body));
Finally you can get the data;
$ json = file_get_contents ('php: // input'); $ Data = json_decode ($ json, true);
Comments
Post a Comment