0

i've tried to take the user's profile photo with using graph api, i take first name, email,fb id exc true, but i fail on taking the user's profile pictures, tried everything and read everything but failed.

After connecting with facebook, it shows a big question mark in the photo areas in my websites' profile picture area for the profiles..

Also there is no problem about temp_fb_id parametre, its inserting that true too

Here is my codes :

// above is the part with sessions getting user id, user email exc.
// $temp_fb_id is the variable that i use for taking the info for user name exc and its working but with photo part, not working , 
 //  img src is showing https://graph.facebook.com//picture?type=square,with a output, big question mark

 $first_name = $user->first_name;
 $last_name = $user->last_name;

 $photo = "https://graph.facebook.com/{$temp_fb_id}/picture?type=square";
 $photothumb = "https://graph.facebook.com/{$temp_fb_id}/picture?type=normal";
 $photolarge = "https://graph.facebook.com/{$temp_fb_id}/picture?type=large";


try {
$fb_insert = "INSERT INTO `members`(`first_name`, `photo_small`, `photo_thumb`, `photo`, `last_name`, `fb_id`) VALUE(:first_name, :photo, :photothumb, :photolarge, :last_name, :temp_fb_id)";
 $fb_insert_do = $db->prepare($fb_insert);
 $fb_insert_do->bindParam(':first_name', $first_name, PDO::PARAM_STR);
 $fb_insert_do->bindParam(':last_name', $last_name, PDO::PARAM_STR);
 $fb_insert_do->bindParam(':photo', $photo, PDO::PARAM_STR);
 $fb_insert_do->bindParam(':photothumb', $photothumb, PDO::PARAM_STR);
 $fb_insert_do->bindParam(':photolarge', $photolarge, PDO::PARAM_STR);
 $fb_insert_do->execute();
 }

 catch(PDOException $e) {
            /* catch and log errors over here. */
        }

Thank You

4

1 回答 1

0

听起来您传递的用户 ID 由于某种原因不正确。您应该将结果与$user->id您存储的结果进行比较,$tmp_fb_id以确保值相等。您应该能够将这些 url 之一粘贴到src标签img中并让它呈现照片。您也可以将 id 替换为$user->username以查看它是否更好。

一个问题:为什么将这些 URL 存储在数据库中,而不是在运行时从存储的 Id 生成它们?如果 Facebook 决定在未来更改 url 方案以获取个人资料照片,您将必须更新所有数据库记录,而不仅仅是几行代码。

于 2012-09-28T16:08:45.903 回答