使用Graph API PHP SDK从特定的Facebook相册获取所有图像 [英] Get all images from specific Facebook album with Graph API PHP SDK

查看:57
本文介绍了使用Graph API PHP SDK从特定的Facebook相册获取所有图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从特定的专辑中抓取所有的图片(总是相同的硬编码的id)。
我从Facebook使用Graph API PHP SDK。这是我的代码:

 <?php 
require'phpfiles / facebook.php';

$ facebook = new Facebook(array(
'appId'=>'aaaa',
'secret'=>'bbbb',
'cookie '=> true
));

$ user_profile = $ facebook-> api('/ 1881235503185 / photos?access_token = cccc');
var_dump($ user_profile);

var_dump输出:

  array(1){[data] =>数组(0){}} 




  • 1881235503185是我的相册的ID这是没有限制的,它对所有人开放

  • access_token是从我的应用页面获取的用于我的fb id的令牌。我没有得到oauth错误。

  • 我有权限(user_photos),并尝试添加其他许多权限。

  • 当我尝试它与Graph API Explorer一起工作。



当我使用Javascript SDK工作正常...

  FB.api('/ 1881235503185 / photos?access_token = cccc',function(response){
alert(response.data [0] .name);
} );

输出:Diep in de put



我忘记了什么吗?

解决方案

我知道了!它应该是:

  $ user_profile = $ facebook-> api('/ 1881235503185 /照片',array('access_token'=>'cccc')); 



新的Facebook PHP SDK应该是:

  $ albumjson = $ facebook-> api('/ 1881235503185?fields = photos' ); 


Hi I'm trying to grab all pictures from a specific album (always the same hardcoded id). I'm using the Graph API PHP SDK from Facebook. This is my code:

<?php
require 'phpfiles/facebook.php';

    $facebook = new Facebook(array(
    'appId'  => 'aaaa',
    'secret' => 'bbbb',
    'cookie' => true
));

$user_profile = $facebook->api('/1881235503185/photos?access_token=cccc');
var_dump($user_profile);

The var_dump output:

array(1) { ["data"]=> array(0) { } }

  • 1881235503185 is the id of MY album that is not restricted, it's open to everybody
  • the access_token is the token I get from my application page for my fb id. I don't get oauth errors.
  • I have the permissions (user_photos) and tryed to add a dozen of other permissions.
  • When I try it with the Graph API Explorer it works to.

When I use the Javascript SDK it works fine...

FB.api('/1881235503185/photos?access_token=cccc', function(response) {
    alert(response.data[0].name);
});

Output: Diep in de put

Am I forgetting something?

解决方案

I got it! It should be:

$user_profile = $facebook->api('/1881235503185/photos', array('access_token' => 'cccc'));

With the new Facebook PHP SDK it should be:

$albumjson = $facebook->api('/1881235503185?fields=photos');

这篇关于使用Graph API PHP SDK从特定的Facebook相册获取所有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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