Solved

Best Buy Developer API

Posted on 2014-11-05
8
143 Views
Last Modified: 2014-11-20
I need help developing a PHP application that uses the Best Buy Developer API.  I can't seem to get the thing to work.  Can someone show me a simple PHP app that does something similar?

Here's a link to the Best Buy Library.

https://developer.bestbuy.com/documentation/stores-api#storesExample6
0
Comment
Question by:Ray Turner
  • 5
  • 3
8 Comments
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40425409
What code have you tried?  Did you get any error messages or other indicators of trouble?  Also, where are you on the novice-to-professional continuum in web application development?  Do you have a budget for this activity?
0
 

Author Comment

by:Ray Turner
ID: 40425511
I've been developing for years using ASP.Net.  Trying to learn some thing new.  PHP isn't tripping me up.  WebServices is very new :)

Here's what I tried.

<?php
$apiKey='';
$radius = $_POST['radius'];
$zipcode = $_POST['zipcode'];

print "<p>Here are a list of stores within $radius miles from $zipcode.</p>";

$requestUrl="http://api.remix.bestbuy.com/v1/stores(area(71.3,-156.8,1000))?show=storeId,name,distance&apiKey={$apiKey}";

$client = new SoapClient($requestUrl);

$response = $client->call('stores',$param);
?>

How do I set the zipcode and radius?
How do I display the response?

Note: I intentionally omitted the API key.
0
 

Author Comment

by:Ray Turner
ID: 40425526
I tried the following.  Still does not work.

<?php
$apiKey='';
$radius = $_POST['radius'];
$zipcode = $_POST['zipcode'];

print "<p>Here are a list of stores within $radius miles from $zipcode.</p>";

$requestUrl="http://api.remix.bestbuy.com/v1/stores(area(71.3,-156.8,1000))?show=storeId,name,distance&apiKey={$apiKey}";

$client = new SoapClient($requestUrl, array(
        "radius" => $radius,
        "zipcode" => $zipcode
           ));

print($client->call('stores'));
?>
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40425966
Asp.net -- that explains it :-)

Please see: https://developer.bestbuy.com/documentation

This looks to me like the implementation of a RESTful API.  More on the theory and practice of APIs here:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12239-Introduction-to-Application-Programming-Interfaces.html

I believe that all you need to do is read a JSON string from the API.  This can be interpreted into a PHP object and parsed with standard PHP object-oriented notation.  If you want to contact me off-list and give me your API key, I'll be glad to show you a script that can get some of the data.  You can find my Gmail address and phone in my profile here:
http://www.experts-exchange.com/members/Ray_Paseur.html
0
 

Author Comment

by:Ray Turner
ID: 40426007
I guess the main problem I'm having is this.  The example they show is:

view-source:http://api.remix.bestbuy.com/v1/stores(area(71.3,-156.8,1000))?format=json&show=storeId,name,distance&apiKey=YourAPIKey

I guess the input is: stores(area(71.3,-156.8,1000))
How do I set this up as parameters?

I guess the output is: show=storeId,name,distance
How do I set this up as parameters?
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40426099
Unless you're fairly advanced in PHP programming it would take too long for us to do this via an online forum.  There are just too many moving parts that would have to be explained.  Better if I give you an example.

If you want to contact me off-list and give me your API key, I'll be glad to show you a script that can get some of the data.  You can find my Gmail address and phone in my profile here:
http://www.experts-exchange.com/members/Ray_Paseur.html
0
 

Accepted Solution

by:
Ray Turner earned 0 total points
ID: 40444392
Found the solution myself.  

How do I set the zipcode and radius?
The parameters are set within the requesting URL
http://api.remix.bestbuy.com/v1/stores(area({$zipcode},{$miles}))?format=json&apiKey={$apiKey}&show=storeId,name,address,city,distance,region,phone,postalCode

 How do I display the response?
$json = json_decode(file_get_contents($requestUrl,true), true);
Then loop through the resulting array to display the information.
0
 

Author Closing Comment

by:Ray Turner
ID: 40454660
This is the best (working) answer.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
write screen output to text file 21 46
website maintenance mode 1 17
Wordpress plugins not working in html 3 19
ASP server side get value 15 18
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now