如何获取Facebook用户的个人资料图片在php [英] How to get a Facebook user's profile picture in php

查看:276
本文介绍了如何获取Facebook用户的个人资料图片在php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PHP的新手,我开发了一种自动将水印应用于手动上传的图像的系统。我想要做的是让用户使用他们的Facebook帐户登录,让PHP从graph.facebook.com获取他们的个人资料,然后将其保存在我的服务器的/ images目录下。

I'm new to PHP and I have developed a system that automatically applies a watermark to a manually uploaded image. What I want to do is have a user sign in with their Facebook account, have the PHP get their profile picture from graph.facebook.com and then save it on my server under the /images directory.

我过去4个半小时一直在尝试这样做,但我不知道我在做什么。我试图使用Facebook的用户图片SDK,但我不知道如何应用它(显然只是复制和粘贴不会工作哈哈)。如果有人可以给我提供一些代码,你肯定会在最后一页提到。

I've been trying to do this for the past 4 and a half hours but I have no idea what i'm doing. I've tried to use Facebook's User Picture SDK but i have no idea how to apply it (clearly just copying and pasting isn't going to work haha). If someone could please provide me with some code, you certainly be mentioned on the final page.

推荐答案

页面

<img src="//graph.facebook.com/{{fid}}/picture">

要保存

$image = file_get_contents('https://graph.facebook.com/'.$fid.'/picture?type=large');
$dir = dirname(__file__).'/avatar/'.$fid.'.jpg';
file_put_contents($dir, $image);

Facebook Graph API

http://graph.facebook.com/abdulla.nilam/picture

这篇关于如何获取Facebook用户的个人资料图片在php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆