Portfolio for Aaron Dale

Projects - Feedback - Code

Best Buy API

This is a simple demonstration of connecting to Best Buy's API using PHP.

The intention of this project was to assist a client with their multi-merchant price searching Android application taking advantage of a cloud server.

Note that I added the FLEX code for the Android project at the end of this page.
function search_bestbuy($search){ global $api_key_bestbuy; $xml = simplexml_load_file("https://api.remix.bestbuy.com/v1/products(name=$search*)?apiKey=$api_key_bestbuy"); $total_results = $xml[total]; if($total_results > 0){ $result['price'] = (string)$xml->product->{'salePrice'}; $result['title'] = (string)$xml->product->{'name'}; $result['image_url'] = (string)$xml->product->{'image'}; $result['store_name'] = (string)$xml->product->{'source'}; $result['description'] = (string)$xml->product->{'longDescription'}; $result['product_url'] = (string)$xml->product->{'url'}; $result1 = json_encode($result); $result['price'] = (string)$xml->product->{'salePrice'}; $result['title'] = (string)$xml->product->{'name'}; $result['image_url'] = (string)$xml->product->{'image'}; $result['store_name'] = (string)$xml->product->{'source'}; $result['description'] = (string)$xml->product->{'longDescription'}; $result['product_url'] = (string)$xml->product->{'url'}; $result2 = json_encode($result); return $result1 . $result2; } else { return 0; } } //FLEX CODE public function product_api_search(path:String, callback:Function):void { var dataSet:String; var urlRequest:URLRequest = new URLRequest(path); var urlLoader:URLLoader = new URLLoader(); urlLoader.dataFormat = URLLoaderDataFormat.TEXT; urlLoader.addEventListener(Event.COMPLETE, urlLoader_complete); urlLoader.load(urlRequest); function urlLoader_complete(evt:Event):void { dataSet = urlLoader.data; trace(dataSet); callback(dataSet); } }

Portfolio - Feedback - Code