Solved

Best Buy Developer API

Posted on 2014-11-05
8
131 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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Ray Turner
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
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
Comment Utility
This is the best (working) answer.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

744 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

8 Experts available now in Live!

Get 1:1 Help Now