Yes that works - of course - hmm I was so shure that I tried that - but still got the same error.
I guess I have to concentrate more! Thanks again Julian. On 16 Dez., 17:42, "Julian (Google)" <[email protected]> wrote: > Hi, > > I think you should look for the node first, before accessing the > attributes: > if ( isset($defaults->email)) {... > > Cheers, > Julian > > On Dec 16, 2:03 pm, "[email protected]" > > <[email protected]> wrote: > > Thank you Julian! > > > That worked like a charm... I did not know about the namespace thing. > > Thanks again. ;-) > > > now I got another little problem with $defaults->email->attributes()- > > > >address; > > > when an entry does not have an emailadress this call ends up in the > > following error message: > > > ....: Node no longer exists > > > Ok that makes sense because it does not exist at all but how do I > > check if this node exists? > > if(!isset($defaults->email->attributes()->address)) does not fix it? > > > I think I overlook something but what? > > > Thank you in advance... > > > On 15 Dez., 18:51, "Julian (Google)" <[email protected]> wrote: > > > > Hi, > > > > You can use SimpleXML using the appropriate XML namespaces, for > > > example: > > > > $feed = $gdata->getFeed($query); > > > > $xml = new SimpleXMLElement($feed->getXML()); > > > $entries = $xml->children('http://www.w3.org/2005/Atom'); > > > > foreach ($entries->entry as $entry ) { > > > $defaults = $entry->children('http://schemas.google.com/g/2005'); > > > echo 'title: '. $entry->title; > > > echo ' email: '.$defaults->email->attributes()->address; > > > echo ' address: '.$defaults->postalAddress; > > > echo "\n"; > > > > } > > > > Cheers, > > > Julian. > > > > On Dec 13, 2:26 pm, "[email protected]" > > > > <[email protected]> wrote: > > > > Hello everybody, > > > > > I could find out the best way to parse through the resuling contact > > > > feed. > > > > > Do you have any suggestions or tips how to do it? > > > > > The situation is, that I have the the whole Atom XLM Feed from > > > > ($feed->getXML()) > > > > > and now I want to parse through the entries to fill my PHP-Array with > > > > the infos like Email Name Street etc. > > > > > Couldn't find the right approach since simplexml can't parse it > > > > right. :-( > > > > > PS: Is simplePie the solution? > > > > > On 14 Nov., 17:31, Kris <[email protected]> wrote: > > > > > > Actually I was able to figure out the PHP code. > > > > > If anyone else is interested in how to add new contacts here is the > > > > > code I used > > > > > > require_once 'Zend/Loader.php'; > > > > > Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); > > > > > Zend_Loader::loadClass('Zend_Gdata_Gapps'); > > > > > Zend_Loader::loadClass('Zend_Gdata_Query'); > > > > > > $email = "YOUR EMAIL"; > > > > > $password = "YOUR PASSWORD" > > > > > > $contactName = "YOUR CONTACT NAME"; > > > > > $contactAddress = "YOUR CONTACT EMAIL ADDRESS"; > > > > > > $client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, > > > > > "cp"); > > > > > $gdata = new Zend_Gdata($client); > > > > > > $extension = new Zend_Gdata_App_Extension_Element('email', null, > > > > > 'http://schemas.google.com/g/2005'); > > > > > $attributes['address'] = array('name'=>'address', 'value' => > > > > > $contactAddress); > > > > > $attributes['rel'] = array('name'=>'rel', 'namespaceUri'=>null, > > > > > 'value' => 'http://schemas.google.com/g/2005#other'); > > > > > $attributes['primary'] = array('name'=>'primary', 'namespaceUri' => > > > > > null, 'value' => 'true'); > > > > > > $extension->setExtensionAttributes($attributes); > > > > > $entry = $gdata->newEntry(); > > > > > $entry->title = $gdata->newTitle($contactName); > > > > > $entry->setExtensionElements(array($extension)); > > > > > $entryResult = $gdata->insertEntry($entry,"http://www.google.com/m8/ > > > > > feeds/contacts/$email/full"); > > > > > > On Nov 13, 2:41 pm, Kris <[email protected]> wrote: > > > > > > > Hello, > > > > > > I am needing code for this. > > > > > > I can get all the data for contact information, and even do some > > > > > > basic work such as > > > > > > $entry = $gdata->newEntry(); > > > > > > $entry->title = $gdata->newTitle('Test Email Address'); > > > > > > > However, I am not sure how to add an email address for the contact. > > > > > > And how would I create a contact group, and add contacts to that > > > > > > contact group? > > > > > > I was able to do it with the javascript api but I need a PHP backend > > > > > > instead. (Or I need better documentation for the Javascript.. it > > > > > > shows > > > > > > how to do basic API stuff, but I can't seem to figure out how to > > > > > > add a > > > > > > contact to a group in Javascript. > > > > > > Any help would be appreciated. > > > > > > Thanks > > > > > > > On Nov 12, 6:33 am, "Julian (Google)" <[email protected]> wrote: > > > > > > > > Hi, > > > > > > > > After the Authentication, you can use a Gdata_Query to get a > > > > > > > Gdata_Feed with Gdata_Entries from the API. > > > > > > > >http://framework.zend.com/apidoc/core/Zend_Gdata/Zend_Gdata_Feed.html... > > > > > > > > require_once 'Zend/Loader.php'; > > > > > > > Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); > > > > > > > Zend_Loader::loadClass('Zend_Gdata_Gapps'); > > > > > > > Zend_Loader::loadClass('Zend_Gdata_Query'); > > > > > > > > // Using Client Login > > > > > > > $client = Zend_Gdata_ClientLogin::getHttpClient("[email protected]", > > > > > > > "PASSWORD", "cp"); > > > > > > > $gdata = new Zend_Gdata($client); > > > > > > > $query = new > > > > > > > Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/ > > > > > > > USER%40domain.com/full'); > > > > > > > $query->setMaxResults(100); > > > > > > > $feed = $gdata->getFeed($query); > > > > > > > > foreach ($feed as $entry) { > > > > > > > $XMLContent = $entry->getXML(); > > > > > > > print_r( $XMLContent ); > > > > > > > > } > > > > > > > > The variable $XMLContent, contains the XML information for each > > > > > > > contact, because there isn't a specific Gdata_Entry for Contacts, > > > > > > > you > > > > > > > need to work with the XML directly. > > > > > > > > What other operations do you need to perform? > > > > > > > > Cheers, > > > > > > > Julian. > > > > > > > > On Nov 6, 7:32 am, rchrd <[email protected]> wrote: > > > > > > > > > help! > > > > > > > > > I was able to have a success login using ClientLogin but what > > > > > > > > will I > > > > > > > > do next? I'm > > > > > > > > onhttps://www.google.com/accounts/ClientLoginHowcani > > > > > > > > use the Auth? And placed it in a variable and make a new > > > > > > > > request. I'm > > > > > > > > usingPHP. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Contacts API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-contacts-api?hl=en -~----------~----~----~----~------~----~------~--~---
