Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Best Buy Developer API

Posted on 2014-11-05
8
Medium Priority
?
191 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 111

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 111

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 111

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

877 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