使用 Facebook Graph API,我可以访问我相册的 JSOD,但不能通过 PHP SDK 进行 api 调用
我的问题是这样的。 我可以使用图形 API 为任何浏览器访问 JSOD,无论 cookie/缓存如何,并将获得许可。但是当我尝试将它与 php sdk 一起使用时,除非我登录,否则它不会显示。
注意:
它访问的用户已通过“offline_access”进行 oAuth 认证。
无论我是否登录,此功能都可以随时随地使用。
https://graph.facebook.com/113401955056/photos?access_token=195481353795312|21c8aad906641dc6f0894861-509590056|IEyCHjWm-3XFpX__eCtv0OMZUisectrezz
除非我已经登录 Facebook,否则此功能不起作用。
<?php
require_once ('../lib/facebook.php');
$app_id = '195481353795312';
$app_secret = 'secretzz';
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true,
));
$photos = $facebook->api("/113401955056/photos?access_token=195481353795312|21c8aad906641dc6f0894861-509590056|IEyCHjWm-3XFpX__eCtv0OMZUisecretz");
foreach($photos['data'] as $photo)
{
echo '<figure class="thumbnail">
<a href="'.$photo['source'].'">
<img src="'.$photo['picture'].'" />
</a>
<figcaption class="thumb_title">'.$photo['name'].'</figcaption>
<!-- end of thumb -->
</figure><!-- end of figure -->
';
}
?>
My problem is this.
I can access the JSOD, for any browsers, regardless of cookies/cache using the graph API and will be granted permission. But when I try to use it with php sdk, it won't show unless I'm logged in.
NOTE:
The user it's access has been oAuth'd with 'offline_access'.
This works from anywhere, anytime, regardless of me being logged in or not.
https://graph.facebook.com/113401955056/photos?access_token=195481353795312|21c8aad906641dc6f0894861-509590056|IEyCHjWm-3XFpX__eCtv0OMZUisectrezz
This doesn't work unless I'm already logged into Facebook.
<?php
require_once ('../lib/facebook.php');
$app_id = '195481353795312';
$app_secret = 'secretzz';
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true,
));
$photos = $facebook->api("/113401955056/photos?access_token=195481353795312|21c8aad906641dc6f0894861-509590056|IEyCHjWm-3XFpX__eCtv0OMZUisecretz");
foreach($photos['data'] as $photo)
{
echo '<figure class="thumbnail">
<a href="'.$photo['source'].'">
<img src="'.$photo['picture'].'" />
</a>
<figcaption class="thumb_title">'.$photo['name'].'</figcaption>
<!-- end of thumb -->
</figure><!-- end of figure -->
';
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,您实际上需要用户令牌才能进行offline_access
之后,您可以以离线方式获取用户数据:
这是关于它的整篇文章 - http://eagerfish.eu/using-facebook-off-line-access-to-post -on-user-wall/
我希望它有帮助。
As far as i know, you actually need the user token for off-line_access
After that, you can get the user data in an off-line manner :
Here's the whole article about it - http://eagerfish.eu/using-facebook-off-line-access-to-post-on-users-wall/
I hope it helps.