Yes, all of the contact data is returned with the feed. I think you
actually want to run your main foreach routine on $feed, not the XML
children. As I understand it, getFeed returns an array of strings
containing XML, and each element of the array is its own XML string
for an individual contact. So, you have to extract from the array each
XML string describing a contact before you convert a string into an
XML object. Here's how my code is structured:
$feed = $gdata->getFeed( $query );
foreach( $feed as $entry )
{
$xml = new SimpleXMLElement( $entry->getXML() );
. . .
}
Also, I'm using an XML-to-Array parser that I found last year in place
of SimpleXML. I would recommend sticking with SimpleXML since it is a
legitimate extension of PHP, but in case you want to see the
alternative, you can find it at
http://mysrc.blogspot.com/2007/02/php-xml-to-array-and-backwards.html.
Hope that helps.
Greg
On Mar 24, 1:53 pm, darie nicolae <[email protected]> wrote:
> Yep everything is clear, my next question is :
>
> I did the query, this is the code :
>
> $query = new Zend_Gdata_Query("http://www.google.com/m8/feeds/
> contacts/" . $username . "/full/?group=" . $grouplink . '&v=2');
> $feed = $gdata->getFeed( $query );
>
> $xml = new SimpleXMLElement($feed->getXML());
> $entries = $xml->children('http://www.w3.org/2005/Atom');
>
> foreach ($entries->entry as $entry ) {
>
> print_r($entry);
>
> The array of entry contains only the name of the contact, but not the
> address email and the other details.
> Should they be returned on this query, or i need to do another query
> based on the contacts name?
>
> Thanks for your help.
>
> Regards,
> Darie Nicolae
>
> On Mar 24, 7:19 pm, Greg Levine <[email protected]> wrote:
>
> > Sorry for not clarifying. If you just recently downloaded Zend Gdata,
> > then you should have the latest version. You can read about specifying
> > a version
> > athttp://code.google.com/apis/contacts/docs/2.0/developers_guide_protoc....
>
> > I read "every request that you send using the Contacts Data API should
> > specify version 2 of the API" to mean that while all functionality of
> > version 1 remains in version 2, you need to specify that you are using
> > version 2 in order to take advantage of the enhancements the most
> > recent version provides. If anyone out there knows better than me (and
> > I'm sure there are plenty), then please correct me if I'm wrong.
>
> > While the HTTP header method is preferred, I wasn't doing anything too
> > complex. So, I just tacked "v=2" onto the end of all of my query
> > URI's. In your case, it would look like the following:
>
> > $query = new Zend_Gdata_Query( "http://www.google.com/m8/feeds/
> > contacts/default/full?group=http://www.google.com/m8/feeds/groups/user
> > %40gmail.com/base/2842a9b10e7d48bb&v=2" );
>
> > Notice the "&v=2" after the group query string value? That's all it
> > takes to specify version 2.
>
> > Greg
>
> > On Mar 24, 10:35 am, darie nicolae <[email protected]> wrote:
>
> > > Hey Greg,
>
> > > Thanks for replying so fast. By version 2 you mean the version two of
> > > the Zend Gdata?
>
> > > On Mar 24, 4:24 pm, Greg Levine <[email protected]> wrote:
>
> > > > darie nicolae,
>
> > > > You're just a little off with your contacts query. All you need to do
> > > > is change "groups" to "contacts" in the URI. When you query for
> > > > groups, you are telling the API that you want to look for a groups
> > > > feed. To query for contacts, you need to tell the API that you want to
> > > > look for a contacts feed. You should leave the group query parameter
> > > > URI exactly as is.
>
> > > > Also, note that I had more success with version 2 requests. For one
> > > > thing, I think the groups query required version 2. And for another,
> > > > you don't need to specify max results, since that property doesn't
> > > > seem to exist in version 2.
>
> > > > Best of luck,
> > > > Greg
>
> > > > On Mar 23, 6:18 pm, darie nicolae <[email protected]> wrote:
>
> > > > > Hello, i have one question regarding the same topic. After i made a
> > > > > query to get the groups i got something like this :
>
> > > > >http://www.google.com/m8/feeds/groups/user%40gmail.com/base/2842a9b10...
>
> > > > > Now in order to get the contacts from this group, the query needs to
> > > > > be :
>
> > > > > $query = new Zend_Gdata_Query("http://www.google.com/m8/feeds/groups/
> > > > > default/full/?group=http://www.google.com/m8/feeds/groups/user
> > > > > %40gmail.com/base/2842a9b10e7d48bb");
>
> > > > > or it should be directly : Zend_Gdata_Query("http://www.google.com/m8/
> > > > > feeds/groups/user%40gmail.com/base/2842a9b10e7d48bb"); ?
>
> > > > > I dont get any response in both ways.
>
> > > > > On Mar 23, 5:55 pm, cwood <[email protected]> wrote:
>
> > > > > > Greg-
>
> > > > > > Try using the whole group id (url-encoded) in your query, like this:
>
> > > > > >http://www.google.com/m8/feeds/contacts/user%40gmail.com/full/?group=...
>
> > > > > > Regards,
> > > > > > Charlie
> > > > > > Spanning Sync
>
> > > > > > On Mar 23, 10:25 am, Greg Levine <[email protected]> wrote:
>
> > > > > > > Okay, it's been two days of trying a number of different things to
> > > > > > > make this work, but I can't seem to figure it out. (Note: I'm
> > > > > > > using
> > > > > > > PHP.)
>
> > > > > > > I'm able to retrieve a list of groups without any trouble. Then,
> > > > > > > using
> > > > > > > a group ID that is returned, I want to query for the contacts in
> > > > > > > that
> > > > > > > group. Let's say that group ID
> > > > > > > ishttp://www.google.com/m8/feeds/groups/user%40gmail.com/base/6.
> > > > > > > I may need to do some work on the URI to make sure the query
> > > > > > > string is
> > > > > > > properly formed, but the code I have (so far) is:
>
> > > > > > > try
> > > > > > > {
> > > > > > > $gdata = new Zend_Gdata( $httpClient );
> > > > > > > $query = new Zend_Gdata_Query(
> > > > > > > "http://www.google.com/m8/feeds/
> > > > > > > contacts/user%40gmail.com/full/?group=6&v=2" ); // I've tried it
> > > > > > > without the "v" query parameter too.
> > > > > > > $feed = $gdata->getFeed( $query );
> > > > > > > print_r( feed );}
>
> > > > > > > catch( Exception $e )
> > > > > > > {
> > > > > > > echo( $e->getMessage() );
>
> > > > > > > }
>
> > > > > > > It would seem that would work because I can replace the
> > > > > > > Zend_Gdata_Query parameter with "http://www.google.com/m8/feeds/
> > > > > > > contacts/user%40gmail.com/full" and print a complete list of my
> > > > > > > contacts, without any restraints or restrictions. So, I'm not
> > > > > > > really
> > > > > > > sure what I'm doing differently. Or, what I'm supposed to do
> > > > > > > differently to print a list of contacts from a specific group.
> > > > > > > I've
> > > > > > > spent a lot of time, specifically
> > > > > > > withhttp://code.google.com/apis/contacts/docs/2.0/reference.html#Parameters,
> > > > > > > trying to come up with a solution. But, it's been to no avail.
> > > > > > > Using
> > > > > > > the above code, I keep receiving "Expected response code 200, got
> > > > > > > 400
> > > > > > > Invalid value for group parameter: 6" as the exception. Using
> > > > > > > variations, I've also received "404 Group not found" on occasion.
> > > > > > > Any
> > > > > > > help is much is appreciated.
>
> > > > > > > Thanks,
>
> > > > > > > Greg
>
> > > > > > > On Mar 21, 2:29 am, Greg Levine <[email protected]> wrote:
>
> > > > > > > > Sorry for cluttering up this discussion group. I was able to
> > > > > > > > figure
> > > > > > > > out the answer.
>
> > > > > > > > It turns out that I only need to specify version 2 of the API
> > > > > > > > in the
> > > > > > > > query.
>
> > > > > > > > $query = new Zend_Gdata_Query(
> > > > > > > > "http://www.google.com/m8/feeds/groups/
> > > > > > > > default/full?v=2" );
>
> > > > > > > > And once I was using version 2, I had to remove the
> > > > > > > > setMaxResults
> > > > > > > > line. That did it.
>
> > > > > > > > On another note, does anyone know how to get the e-mail address
> > > > > > > > and/or
> > > > > > > > nickname of the authenticated user when using AuthSub?
>
> > > > > > > > Thanks again,
>
> > > > > > > > Greg
>
> > > > > > > > On Mar 20, 11:51 pm, Greg Levine <[email protected]> wrote:
>
> > > > > > > > > I am trying to extract all contacts from a specified group,
> > > > > > > > > with the
> > > > > > > > > goal of firing off an e-mail to each address in the group. I'm
> > > > > > > > > starting by displaying a page that lists the authenticated
> > > > > > > > > user's
> > > > > > > > > groups. When the user clicks on a group, he/she will see a
> > > > > > > > > form in
> > > > > > > > > which the e-mail content will be typed. Upon submitting the
> > > > > > > > > e-mail,
> > > > > > > > > each of the contacts in the selected group will be sent the
> > > > > > > > > e-mail
> > > > > > > > > using PHP's mail function.
>
> > > > > > > > > I've successfully authenticated a user using AuthSub and am
> > > > > > > > > able to
> > > > > > > > > produce a list of contacts by querying
> > > > > > > > > "http://www.google.com/m8/feeds/
> > > > > > > > > contacts/default/full" with the Zend_Gdata_Query method.
> > > > > > > > > However, I am
> > > > > > > > > unable to produce a list of the groups associated with the
> > > > > > > > > authenticated account. The code I am trying is as follows:
>
> > > > > > > > > $gdata = new Zend_Gdata( $httpClient );
> > > > > > > > > $query = new Zend_Gdata_Query(
> > > > > > > > > "http://www.google.com/m8/feeds/groups/
> > > > > > > > > default/full" );
> > > > > > > > > $query->setMaxResults( 100 );
> > > > > > > > > $feed = $gdata->getFeed( $query );
>
> > > > > > > > > foreach( $feed as $entry )
> > > > > > > > > {
> > > > > > > > > $xml= $entry->getXML();
> > > > > > > > > print_r( $xml );
>
> > > > > > > > > }
>
> > > > > > > > > I don't see any errors. Just a blank page. Nothing is
> > > > > > > > > returned. Any
> > > > > > > > > ideas as to why it might be failing?
>
> > > > > > > > > Thanks in advance.
>
> > > > > > > > > Greg
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---