2012-03-30 36 views
1

我想在我的应用程序中使用Facebook用户个人资料图片。Facebook应用程序 - 用户图片?

我想我应该用下面的函数,但我不知道这是正确的:

 public function getImg() { 
     $img = file_get_contents('https://graph.facebook.com/'.getUser().'/picture?type=normal'); 
     return $this->img; 
    } 

我的目标是将个人资料图片上的另一个图像的顶部。

我想我不得不使用这样的事情:

ImageCopy ($picture , $source, 445, 160 , 0 , 0 , $width , $height); 

总之...我要使用用户的个人资料图片的添加它在另一张照片,我该怎么办呢?

+0

http://stackoverflow.com/questions/2821061/facebook-api-how-do-i-get-a-facebook-users -profile-image-through-the-fb-api – sakhunzai 2012-03-30 11:44:24

+0

你有没有试过你在这里给我们看的代码?如果是,发生了什么问题? – ThdK 2012-03-30 11:46:56

+0

嗯,我试过了,但可悲的是它没有奏效。配置文件图片不会添加到其他图片上。 – Salexes 2012-03-30 13:00:57

回答

0

我不知道PHP,但我认为从here这个例子可以帮助你:使用下面的代码

<?php 
// Create image instances 
$src = imagecreatefromgif('php.gif'); 
$dest = imagecreatetruecolor(80, 40); 

// Copy 
imagecopy($dest, $src, 0, 0, 20, 13, 80, 40); 

// Output and free from memory 
header('Content-Type: image/gif'); 
imagegif($dest); 

imagedestroy($dest); 
imagedestroy($src); 
?> 
1

抢用户资料图:

$userpic = imagecreatefromjpeg("http://graph.facebook.com/".$user_id."/picture?type=normal"); 

现在放置在你的主照片:

$mainphoto = imagecreatefromjpeg("path/to/main/photo.jpg"); 
imagecopymerge($mainpic, $userpic, $x, $y, -2, -2, 55, 55, 100); 

现在$mainphoto将包含mai它的照片和用户图片。 你必须遵循相同的想要放在mainphoto上的所有用户图片。

终于下载服务器上的照片和释放内存:

imagejpeg($mainphoto, "save_as_this_name.jpg", 100); 
imagedestroy($mainphoto); 
+0

感谢您的详细解答。你的意思是我必须这样做吗?公共职能getImg(){ $ userpic = imagecreatefromjpeg(“http://graph.facebook.com/”。$ user_id。“/ picture?type = normal”); } – Salexes 2012-03-30 15:40:19

+0

这就是我的“傀儡”的开端。php“看起来像 foreach((array)$ _ CONFIG ['texte'] as $ key => $ val){ \t $ ttfsize = $ val ['fontNameSize']; \t $ ttf = $ val ['fontNamePfad' ]; \t $ t_x = $ VAL [ 'X']; \t $ t_y = $ VAL [ 'Y']; \t \t如果($ VAL [ 'BILD']){ \t \t $源= @ ImageCreateFromPNG($ hippibild); \t \t列表($宽度,$高度)=和getimagesize($ hippibild); \t \t imagecopy的($图片,$源,$ t_x,$ t_y,0,0,$宽度,$开平ght); – Salexes 2012-03-30 15:51:05

+0

$ source = @ImageCreateFromPNG(getImg()); \t \t list($ width,$ height)= getimagesize(getImg()); ImageCopy($ picture,$ source,430,80,0,0,$ width,$ height); \t} else { \t \t $ text = $ val ['TEXT']; \t \t $ text = str_replace('%birthday%',$ birthday,$ text); 新的prob.not肯定你的代码。请帮助:) – Salexes 2012-03-30 15:51:18

相关问题