I want 开发者_高级运维to create an application where I'll create an image from the application user's friends profile image.
In this image there are 4 photos of friends, I want to create a new [single] image in that image all of the images will be pasted.
What is the best way to go about doing this?
if i get your question right you will first need all their pictures, try the following:
$facebook_friends = json_decode(file_get_contents('https://graph.facebook.com/me/friends?access_token=' .
$_SESSION['cookie']['access_token']), true);
$friends = $facebook_friends['data'];
foreach($friends as $key => $values){
echo '<img src="http://graph.facebook.com/'.$value['id'].'/picture" />';
}
Use imagecopymerge()
function to add the four jpg
profile images in a single image. Then, use the graph API
to get user friend .
imagecopymerge($mainimg, $friends, $dst_x, $dst_y, 0, 0, $src_w, $src_h, $pct);
Here mainimg
is representing your Background image. You can build an individual image in php using GD
functions.
精彩评论