没有登录FB帐户就发布照片是真的吗?我阅读了有关 access_token 的信息,它与简单的墙贴消息完美配合,但是当我在没有登录 ti FB 的情况下使用 access_token 发布照片时,我总是出错。请帮帮我。
<?php
ini_set('display_errors', 'on');
error_reporting(E_ALL);
require 'facebook-php-sdk-master/src/facebook.php';
$photo = 'mma.jpg';
$message = 'TEST MESSAGE';
$facebook = new Facebook(array(
'appId' => 'APP ID',
'secret' => 'APP_SECRET',
'fileUpload' => true,
'cookie' => true,
));
$loginUrl = $facebook->getLoginUrl(array(
'canvas' => 1,
'fbconnect' => 0,
'scope' => 'offline_access,publish_stream,photo_upload'
));
$user = $facebook->getUser();
if($user){
echo $facebook->getAccessToken();
}
$tokenac = $facebook->getAccessToken();
$post = array(
'access_token' => "$tokenac",
'message' => 'Test post' . date('Y-m-d H:i:s'),
);
$res = $facebook->api('/10000******8933/feed', 'POST', $post);
echo 'ID: ',$res['id'];
我试过这样,但它不起作用。任何人都可以帮忙吗
require 'facebook-php-sdk-master/src/facebook.php';
$photo = 'mma.jpg';
$message = 'Nope, this message last after 10:2222 (test)';
$facebook = new Facebook(
array(
'appId' => '646351572060837',
'secret' => 'e4215791489cce26778ed02403a04427',
'fileUpload' => true,
'cookie' => true,
)
);
$loginUrl = $facebook->getLoginUrl(
array(
'canvas' => 1,
'fbconnect' => 0,
'scope' => 'offline_access,publish_stream,photo_upload'
)
);
$tokenac = $facebook->getAccessToken();
$res = $facebook->api(
'/100001776698933/photos', 'POST',
array(
'access_token' => $tokenac,
'source' => '@' . $photo,
'message' => $message,
)
);
echo 'ID: ',$res['id'];
总是有照片出现此错误,致命错误:未捕获的 OAuthException:需要用户访问令牌才能请求此资源。在第 1254 行的 base_facebook.php 中抛出