You should use "$val->getResponseBody()" which contains the raw XML data.
Le jeudi 8 mars 2012 15:34:14 UTC+1, B8X a écrit :
>
> Tell me please what do you use for the variable xmlresponse? I am
> using. such a code to get contact information:
> require_once ('google-api-php-client/src/apiClient.php');
>
>
>
> $ Client = new apiClient ();
> $ Client-> setApplicationName ('Google Contacts PHP Sample');
> $ Client-> setScopes ("http://www.google.com/m8/feeds/");
> / / Documentation: http://code.google.com/apis/gdata/docs/2.0/basics.html
> / / Visit https://code.google.com/apis/console?api=contacts to
> generate your
> / / Oauth2_client_id, oauth2_client_secret, and register your
> oauth2_redirect_uri.
> $ Client-> setClientId ('somecode');
> $ Client-> setClientSecret ('somecode');
> $ Client-> setRedirectUri ('somecode');
> / / $ Client-> setDeveloperKey ('insert_your_developer_key');
>
>
>
>
> if (isset ($ _GET ['code'])) {
> $ Client-> authenticate ();
> $ _SESSION ['Token'] = $ client-> getAccessToken ();
> $ Redirect = 'http://'. $ _SERVER ['HTTP_HOST']. $ _SERVER
> ['PHP_SELF'];
> header ('Location:'. filter_var ($ redirect, FILTER_SANITIZE_URL));
> }
>
>
>
>
> if (isset ($ _SESSION ['token'])) {
> $ Client-> setAccessToken ($ _SESSION ['token']);
> }
>
>
>
>
> if (isset ($ _REQUEST ['logout'])) {
> unset ($ _SESSION ['token']);
> $ Client-> revokeToken ();
> }
>
>
>
>
> if ($ client-> getAccessToken ()) {
> $ Req = new apiHttpRequest ("https://www.google.com/m8/feeds/
> contacts/default/full<https://www.google.com/m8/feeds/contacts/default/full>")
>
> ;/ / create requests string contacts /
> default / full
> / / $ Req = new apiHttpRequest ("http://schemas.google.com/
> contacts/2008/rel <http://schemas.google.com/contacts/2008/rel> # photo")
> ;/ / create requests string
> $ Val = $ client-> getIo () -> authenticatedRequest ($ req);
> print "<pre>";
> print_r ($ val);
> print "</ pre>";
> / / The contacts api only returns XML responses.
> $ Response = json_encode (simplexml_load_string ($ val->
> getResponseBody ()));
> print "Debugging code for Google API <pre>". print_r (json_decode ($
> response, true), true). "</ Pre>";
>
>
>
>
> / / The access token may have been updated lazily.
> $ _SESSION ['Token'] = $ client-> getAccessToken ();
> } Else {
> $ Auth = $ client-> createAuthUrl ();
> }
>
>
>
>
> if (isset ($ auth)) {
> print "<a class=login href='$auth'> Connect Me! </ a>";
> } Else {
> print "<a class=logout href='?logout'> Logout </ a>";
> }
> ___________
> How to follow the code of your part of the code to display a list of
> contacts, emails and not merely the title and content???
>
> On 13 фев, 11:46, Rajeash <[email protected]> wrote:
> > Hi,
> >
> > I need to fetch gmail contacts using Oauth2.0 using PHP
> >
> > $xml= new SimpleXMLElement($xmlresponse);
> > $xml->registerXPathNamespace('gd', 'http://schemas.google.com/g/
> > 2005');
> > $result = $xml->xpath('//gd:email');
> >
> > foreach ($result as $title) {
> > echo $title->attributes()->address;
> >
> > }
> >
> > in the above code i am retrieving all email of the contacts.
> > Can anyone tell me that how i need to pick all infornation of my
> > contact like like
> > Firstname
> > Lastname
> > Phonenumber,
> > Email.
> >
> > As of now it is displaying only email when i am using above code.
> > I need a same which should retrieve Email, firstname, lastname and
> > phone number.
--
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" 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://code.google.com/apis/contacts/community/forum.html