skip to Main Content

I’m studing about ebay api’s on these days but stil i cant figure out how to get ebay item id using full item url(http://www.ebay.com/ctg/TomTom-XXL-550M-US-including-Puerto-Rico-Canada-Mexico-Automotive-GPS-Receiver-/86127922?)?

i tried in many ways but negetive pls help me!is there any using apis? or any other way i just need the ebay item number..

3

Answers


  1. This isn’t tested, just wrote it out real quick. It should at the very least give you the general idea. It assumes that the id will always be the segment of the url after the last /. If thats not the case, this answer will be pretty useless.

    $ebayUrl = "http://www.ebay.com/ctg/TomTom-XXL-550M-US-including-Puerto-Rico-Canada-Mexico-Automotive-GPS-Receiver-/86127922?";
    $pos     = strrpos($ebayUrl, '/') + 1;
    $id      = substr($ebayUrl, $pos);
    
    //if you want to remove the question mark left at the end
    $id      = str_replace("?", "", $id);
    
    echo $id;
    
    Login or Signup to reply.
  2. Other alternative could be:

    $parts = explode('/', 'http://www.ebay.com/ctg/TomTom-XXL-550M-US-including-Puerto-Rico-Canada-Mexico-Automotive-GPS-Receiver-/86127922?');
    $id = trim(end($parts), '?');
    echo $id;
    
    Login or Signup to reply.
  3. Depending on where you need to do this, you may be able to use ebayItemID

    e.g. (javascript) var itemid = ebayItemID;

    I’ve used this method to add a ‘buy now’ button to product descriptions.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search