Reputation: 153
I managed to create a Facebook App using PHP. The visitor uploads the photo from my website. Under each photo there is my custom message. Below is the code:
$args = array(
'message'=> "This picture is brought to you by Miss Little Girl",
'image' => '@' . $img,
I want the message to include the Username of the person who uploaded the picture, and I manged to find this code:
$uid = "1234567890"; //User's Facebook ID, set the value as "me" if publishing on logged in user's wall
$ufname = "Nikka Mormola"; // User's Full name on Facebook
$attachment = array(
'message'=> "Happy Birthday, @[".$uid.":1:".$ufname."]!",
);
try {
$post = $facebook->api('/'.$uid.'/feed', 'post', $attachment);
print_r($pp); //show the tagged post ID
} catch (FacebookApiException $e) {
//Error
exit;
}
Unfortunately I haven't managed to integrate the code below to the one above it. Can you please help me? When I tried to integrate it "Happy Birthday, @[".$uid.":1:".$ufname."]!",
How can I display the username of the person of the person instead of the $uid can you please provide me with sample PHP code please?
Thanks.
Upvotes: 2
Views: 376
Reputation: 6030
not every user has a username, anyway if user has a username, you can get it this way:
$user = $facebook->api('/'.$uid);
$username = isset($user['username']) ? $user['username'] : '';
by the way, how you get the user id and user name? I think you already have user object
Upvotes: 1