Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Best Buy Developer API

Posted on 2014-11-05
8
Medium Priority
?
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn how to dynamically set the form action using jQuery.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

718 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