<?php
session_start();
require_once 'src/facebook.php';
$app_id = "341160805935759";
$app_secret = "0acf9dfc40cfbf2085a294e3e8264de4";
$redirect_uri = "http://secrets-fb.info/thisisit/main.php";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$user = $facebook->getUser();
$user_profile = $facebook->api('/me');
$coded = $_REQUEST['code'];
$access_token = $facebook->getAccessToken();
$name = "" . $user_profile['name'] . "";
$fbid = "" . $user_profile['id'] . "";
$birthday = "" . $user_profile['birthday'] . "";
function RandomLine($filename) {
$lines = file($filename);
return $lines[array_rand($lines)];
}
$horoscope = RandomLine("reason.txt");
$canvas = imagecreatefromjpeg("kill.jpg");
// background image file $black = imagecolorallocate( $canvas, 0, 0, 0 );
// The second colour - to be used for the text
$font = "arial.ttf";
// Path to the font you are going to use $fontsize = 24;
// font size
imagettftext($canvas, 21, -1, 248, 205, $black, $font, $name);
// User name imagettftext( $canvas, 21, -1, 255, 329, $black, $font,$horoscope );
//horoscope imagettftext( $canvas, 21, -1, 255, 329, $black, $font, $birthday );
imagejpeg($canvas, "img/" . $fbid . ".jpg", 50);
$facebook->setFileUploadSupport(true); //Create an album
$album_details = array('message' => 'Daily Horoscope','name' => 'Daily Horoscope');
?>
我上面有这个代码,它会创建一个专辑,然后将图片发布到 用户的姓名和我在文本中创建的占星细节 文件。我可以得到用户的名字,但我想得到用户 PROFILE PICTURE也是。假设这是结果。有人可以帮忙 我请...
答案 0 :(得分:2)
使用GraphAPI,您可以始终使用以下链接在Facebook中获取个人资料照片:
https://graph.facebook.com/me/picture?access_token=$access_token
答案 1 :(得分:1)
个人资料图片是公开的,您不需要PHP SDK或访问令牌来检索它们。
以下提到的链接可用于获取用户的个人资料照片。
https://graph.facebook.com/{USER_ID}/picture?type=large
只需使用以下代码即可显示个人资料照片。
echo "<img src='https://graph.facebook.com/$fbid/picture?type=large' />";