Not signed in (Sign In)
Welcome, Guest

Did you know that there is a whole world of functionality you're not seeing? If you have an account, sign in now.

If you don't have an account, apply for one now.

Bottom of Page
phpFlickr Features: Retrieving list of contacts (contacts_getPublicList)
  1.  
1 to 5 of 5
Feb 3rd 2006
I have been trying to retrieve the contact list for a given user, but so far i had no luck working through the array. I have been using:

$contacts = $f->contacts_getPublicList($nsid);

For some reason I can not create a foreach statement that effectively retrieves the information I need, such as username for example. I tried to take other functions as an example but no luck. The array prints fine, just having troubles to create working foreach statement.

Something like $contacts[0]["_attributes"]["username"] works but is hardly useful in this case. Any suggestions?
Feb 3rd 2006
Try this approach:

$contacts = $f->contacts_getPublicList($nsid);
foreach ($contacts as $contact) {
$username = $contact['username'];
echo $username;
}
Feb 3rd 2006
Thank you Dan, that was a very swift and accurate response. I am impressed with the work you have done on phpFlickr!
Apr 12th 2006
foreach works great when there are multiple contacts. When there is only one contact for a user, the contact info isn't contained in an indexed array.

print_r($contacts) returns
Array ( [_name] => contact [_attributes] => Array ( [nsid] => 99999999@N00 [username] => mycontact [iconserver] => 32 [ignored] => 0 ) [_value] => [nsid] => 99999999@N00 [username] => mycontact [iconserver] => 32 [ignored] => 0 )

foreach returns
c
mycontact

9
m
3
0
Apr 20th 2006
This is a bug. On line 543 in phpFlickr.php change ['id'] to ['nsid']. This is also affecting contacts_getList.
  1.  
1 to 5 of 5
Top of PageBack to discussions