我设置了所需的权限并获得了路径,即我/照片 这显示:
{
"data": [
{
"id": "78768",
"from": {
"name": "Dai beckham",
"id": "135656456"
},
"picture": "link here",
"source": "link here",
"height": 540,
"width": 720,
"images": [
{
"height": 720,
"width": 960,
"source": "link here"
},
然后我尝试像echo $user_graph['data']['source'];
一样回显图像路径,但我收到错误
"注意:未定义的索引:A:文件名中的源.php在第 12 行"
我不知道我哪里出了问题。 提前谢谢。
您需要先将响应转换为数组,然后才能像这样访问它。
目前它是 JSON 格式。您可以使用本机json_decode()
函数为您转换它。
$array = json_decode($response, true);
$source = $array['data']['source'];
$array = json_decode($response, true); //it will provide array
$source = $array['data']['source']; and access it now
只需从此网址获取
http://graph.facebook.com/ankit.varia/picture
输入你的名字而不是我的 ankit.varia(me)= (你的)