getSessionedUser(); if ($yahoo_user == NULL) { fatal_error("yahoo_user"); } // PROFILE: $user_profile = $yahoo_user->loadProfile(); if ($user_profile == NULL) { fatal_error("user_profile"); } $nickname = $user_profile->nickname; $guid = $user_profile->guid; echo "

Profile Info

"; print("Name: $nickname" . "
"); print("GUID: $guid" . "
"); print("Sex: $user_profile->gender"); // UPDATES: // Add an update to the user's update list. // Assign a unique values to the variable suid. $suid = sprintf("%d%s",time(),$user_profile->guid); // Create a title and link to the event. $title = "My Day at Work"; $link_back_to_event = "http://yourblogsite.com/?blockID=123me"; // Pass the SUID, title and link to event to method insertUpdate. $yahoo_user->insertUpdate($suid, $title, $link_back_to_event); // Get updates and display the name of update with link to event. echo "

Status Updates

"; $user_updates = $yahoo_user->listUpdates(0,20); if ($user_updates == NULL) { fatal_error("user_updates"); } foreach($user_updates as $update) { $desc = $update->loc_longForm; $icon = $update->loc_iconURL; $link = $update->link; $update_name = $update->loc_localizedName; $image_tag = sprintf('%s', $icon, $update_name); $link_tag = sprintf('%s', $link, $desc); print("

"); echo "$image_tag"; echo "$link_tag"; print("

"); } // CONTACTS: // Obtain list of contacts and the names of each contact. $start = 0; $count = 20; $user_contacts = $yahoo_user->getContacts($start,$count); if ($user_contacts == NULL) { fatal_error("user_contacts"); } echo "

$nickname's Contacts:

"; foreach($user_contacts as $contact) { foreach($contact as $obj) { if(is_array($obj)) { foreach($obj as $element) { foreach($element->fields as $field) { if(!is_string($field) && strlen($field->value->givenName)>0) { print($field->value->givenName); echo " "; print($field->value->familyName); echo " / "; } } } } }; echo "
"; } // CONNECTIONS: // Display the names and images of ten connections $start = 0; $count = 10; $connections = $yahoo_user->getConnections($start,$count,$total); if ($connections == NULL) { fatal_error("connections"); } echo "

$nickname's Connections:"."

"; foreach($connections as $connection) { $imageUrl = $connection->image->imageUrl; $profileUrl = $connection->profileUrl; $connection_nickname = $connection->nickname; if($imageUrl != "") { $image_tag = sprintf('%s', $imageUrl, $connection_nickname); echo "$image_tag"; } $link_tag = sprintf('%s', $profileUrl, $connection_nickname); echo "$link_tag"; echo "
"; } echo "

"; // STATUS: echo "

$nickname's Status Message:

"; // Get the user's status (presence). $presence = $yahoo_user->getPresence(); if ($presence == NULL) { fatal_error("presence"); } if (!empty($presence->value->status)) { print($presence->value->status); print(" (" . $presence->starttime . ")" ); } else { echo "$nickname has no status message."; } // Change the user's status. $yahoo_user->setPresence("I'm on a raft floating down the Amazon."); // Get the status again to verify that the set worked. $presence = $yahoo_user->getPresence(); print ( "
" ); print($presence->value->status); print(" (" . $presence->starttime . ")" ); function fatal_error($object_name) { // Print error message and and then exit the script. print ("
"); print ("Error detected in mysocial.php: Cannot get $object_name."); print ("
"); print ("In the Application Editor, verify that the Permissions are set correctly."); print ("
"); print ("Also, make sure that the Consumer Key and Consumer Secret in the source code are correct."); exit; } ?>