Search code examples
zend-frameworkgoogle-base

How to get unique URL identifier after inserting item in Google Base with Zend Gdata API?


I need to get the unique URL identifier for the product that is created after inserting an item into Google Base using the Zend_Gdata_Gbase library.

I can't seem to do this. I am finding a startling lack of documentation online about manipulating the objects used in these applications.

The url that I add to the object does not work to retrieve the base item later, which is why I need to get the one that google generates upon submission.

I am writing a program that will need to be able to delete content at a later date, and thus will need to store that information in order to keep the website synced with the Google Base feed.

Thanks in advance for any help.


Solution

  • The answer is... after having created the new entry, you run the code to insert the entry.

    $dryRun = false;
    $createdEntry = $service->insertGbaseItem($newEntry, $dryRun);
    
    $http = $createdEntry->service->getHttpClient();
    $headers = $http->getLastResponse()->getHeaders();
    return $headers['Location'];
    

    This gives you the unique URL that is different from the URL you can insert as a link. If you aren't inserting your own links, you can access the unique url much more easily:

    return $createdEntry->link[0]->href;
    

    I hope this helps somebody else.