Solved

Best Buy Developer API

Posted on 2014-11-05
8
153 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 110

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 110

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 110

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

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!

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

751 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