开发者

Using Facebook Graph API I can access the JSOD for my album but not through an api call via PHP SDK

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>
    <figcaptio开发者_运维百科n class="thumb_title">'.$photo['name'].'</figcaption>
    <!-- end of thumb -->
    </figure><!-- end of figure -->
    ';
  }
?>


As far as i know, you actually need the user token for off-line_access

$session = $facebook->getSession();

if ($session) {
    // you need to store the $session['access_token']; 
}

After that, you can get the user data in an off-line manner :

$token =  array(

    'access_token' => 'TOKEN HERE'

);

$userdata = $facebook->api('/me', 'GET', $token);

Here's the whole article about it - http://eagerfish.eu/using-facebook-off-line-access-to-post-on-users-wall/ I hope it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜