Jump to content


  • Posts

  • Joined

  • Last visited

cpcdev84's Achievements


Newbie (1/7)



  1. I figured out how display a photo.. here's the existing code I'm using now: <?php$btapi = 'http://api.traderonline.com/vehicles/queueSearch?xml=%3CTOLData%3E%3Crealm%3Ecycle%3C%2Frealm%3E%3CperPage%3E25%3C%2FperPage%3E%3Clatitude%3E36.847868%3C%2Flatitude%3E%3Clongitude%3E-76.292010%3C%2Flongitude%3E%3Ctype%3E356953%3C%2Ftype%3E%3Ccategory%3E-1%3C%2Fcategory%3E%3Cradius%3E25%3C%2Fradius%3E%3CmakeName%3EHONDA%3C%2FmakeName%3E%3Ccondition%3Eused%3C%2Fcondition%3E%3CminPrice%3E0%3C%2FminPrice%3E%3CmaxPrice%3E0%3C%2FmaxPrice%3E%3CminYear%3E0%3C%2FminYear%3E%3CmaxYear%3E0%3C%2FmaxYear%3E%3C%2FTOLData%3E';$xml = simplexml_load_file($btapi);$images = $xml->DATA->ADS->AD->DETAIL->PHOTO->IMAGE;foreach($xml as $test) {echo "<strong>Year:</strong> ".$xml->DATA->ADS->AD->DETAIL->YEAR."<br>";echo "<strong>Make:</strong> ".$xml->DATA->ADS->AD->DETAIL->MAKE."<br>";echo "<strong>Model:</strong> ".$xml->DATA->ADS->AD->DETAIL->MODEL."<br>";echo "<strong>Price:</strong> "."$".$xml->DATA->ADS->AD->DETAIL->PRICE."<br>";echo "<strong>Images:</strong>"."<br>";echo "<img src='$images'>"."<br><br>";}?> and the output:'s working but only showing one unique listing. Can you tell me how to re-write it to show all the listings? Thank you again!
  2. Thank you! I am now able to display an individual value. What happens if I want to use this xml instead? http://api.traderonline.com/vehicles/queue...3C%2FTOLData%3EWhat would it look like to pull a photo from that? I'm just trying to comprehend how the paths work.. do you need to start with .$xml->I'm now experimenting with this codeecho "<strong>Category Name:</strong> ".$xml->PWC->ITEM[0]->CATEGORY_NAME."<br>";echo "<strong>Category ID:</strong> ".$xml->PWC->ITEM[0]->CATEGORY."<br>";echo "<strong>Type ID:</strong> ".$xml->PWC->ITEM[0]->TYPE."<br>";echo "<strong>Model:</strong> ".$xml->PWC->ITEM[0]->MODEL."<br>";
  3. Thank you. Following those examples I'm now able to drill down into the sub categories using this:echo $btapi->{'PWC'}->children()->getName(); The intention is to go into the first child called "PWC" and then into its children. I'm able to display the names of the children but how can I display the actual values and not just the names?I tried to echo the $value variable using this: $value = (string) $btapi->{'PWC'}->children(); but it's not showing any of the values. Any suggestions?Thank you for your help. Slowly its coming together
  4. Now i added this code: foreach($btapi->children() as $child) { echo $child->getName().": "; } and its showing the first set of children.. Is there a way to display one individual child in that set rather than all of them?Thanks!
  5. Hello again,I am still attempting to parse the data. I've begun looking into simplexml. here's what i have so far:<?php$btapi = 'http://api.traderonline.com/vehicles/getTypes?xml=%3CTOLData%3E%3Crealm%3Ecycle%3C%2Frealm%3E%3C%2FTOLData%3E';$btapi = simplexml_load_file($btapi); ?> Is this the correct way to connect to an api?How can I display data from that point? I can provide the link to that API documentation again.Could you possible give me an example of how to display some data from that API?Thank you for the help. I hope i'm on the right track.
  6. Thanks for the clarification. So am I starting the "parse" correctly with the code I included above? This is what I have so far: but I'm not sure if I'm pulling the data correctly to begin with.. and then how to separate it/style it from that point.I REALLY appreciate your help btw. I'd be nowhere without forums and books.
  7. Sorry for being vague.. I am doing my best to understand what I'm trying to solve more as I go along. Here's a link to the API documentation:Now I believe they have created some of their own functions to parse, not completely sure though. I am guessing I will want to transform it using XSLTThanks for your continued help.
  8. I think I'm heading in the right direction possibly.. I'm using this code sample <?php// Request Yahoo! REST Web Service using// file_get_contents. PHP4/PHP5// Author: Rasmus Lerdorf and Jason Levitt// February 1, 2006error_reporting(E_ALL);$request = 'http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query='.urlencode('Al Gore').'&results=1';// Make the request$xml = file_get_contents($request);// Retrieve HTTP status codelist($version,$status_code,$msg) = explode(' ',$http_response_header[0], 3);// Check the HTTP Status codeswitch($status_code) { case 200: // Success break; case 503: die('Your call to Yahoo Web Services failed and returned an HTTP status of 503. That means: Service unavailable. An internal problem prevented us from returning data to you.'); break; case 403: die('Your call to Yahoo Web Services failed and returned an HTTP status of 403. That means: Forbidden. You do not have permission to access this resource, or are over your rate limit.'); break; case 400: // You may want to fall through here and read the specific XML error die('Your call to Yahoo Web Services failed and returned an HTTP status of 400. That means: Bad request. The parameters passed to the service did not match as expected. The exact error is returned in the XML response.'); break; default: die('Your call to Yahoo Web Services returned an unexpected HTTP status of:' . $status_code);}// Output the XMLecho htmlspecialchars($xml, ENT_QUOTES);?> How can I output the code so that I can style it using HTML?
  9. Thanks for the info.. it's a private API through the company I work for. There isn't any documentation on how to connect to it, just examples of how to parse the data. Could you give me an example of how to call an API through PHP?
  10. Hi,I'm wondering how to connect to an API? I am fairly new to XML... do I connect to it using XML or if I'm using PHP around it do I call it through PHP? Any help is appreciated. I'm trying to parse data from the API. Also, what information do I need to know about the API in order to connect to it?Thanks!
  • Create New...