- Where Developers Learn, Share, & Build Careers
I want to get the contact's name from Google Contacts without any luck. However, I am unable to remove an email address. Does anyone show me what I am doing?
$ xmlresponse = file_get_contents ('https://www.google.com/m8/feeds/contacts/default/full?oauth_token=' $ accesstoken); // Simple xml $ xml = Reading XML using new SimpleXMlelement ($ xmlresponse); $ Xml- & gt; Register XPathNamespace ('gd', 'http://schemas.google.com/g/2005'); $ NameFirst = $ xml- & gt; Xpath ('// gd: given'); // I also have / gd: name $ result = $ xml- & gt; Xpath ('// gd: email') is tried; Forex Currency ($ nameFirst $ nameF) {echo $ nameF- & gt; GetName (); } Forex Currency ($ $ $ Title) {echo $ title- & gt; Attribute () - & gt; Address "& lt; br & gt;"; }? & Gt;
XML received from Google Contacts API, name node was a normal XML node " Title "but the email was a parameter in a gdata tag gd: email . Given the possibility of several email addresses, I used the following to remove an array of single name / email pairs: $ req = new Google_HttpRequest ("https://www.google .com / m8 / feed / contact / default / property-e-mail / "); $ Val = $ this- & gt; Client- & gt; GetIo () - & gt; Certified request ($ req); $ Xml = simplexml_load_string ($ val-> MillerSponsbody ()); $ Xml- & gt; Register XPathNamespace ('gd', 'http://schemas.google.com/g/2005'); $ Output_ar = array (); Foreach ($ xml- & gt; as entry $ entry) {foreach ($ entry-> xpath ('gd: email') as $ email) {$ output_array [] = array (string) $ Entry-> Title, (string) $ email-> Attributes () -> Addresses); }}
Comments
Post a Comment