SDK 4.0 Facebook,没有对话框请求权限publish_actions

时间:2014-09-03 06:57:44

标签: php facebook sdk scope

我在facebook上创建了一个应用程序,通过PHP SDK 4.0我创建了登录,我需要对feed有写权限,但即使我们已经添加了权限,当我没有登录apparre更多的窗口框来批准和授予权限。

这是使用的代码:

<?php session_start(); 
require 'Facebook/autoload.php'; 




use Facebook\FacebookSession; 
use Facebook\FacebookRequest;
use Facebook\GraphObject;
use Facebook\FacebookRequestException;
use Facebook\FacebookRedirectLoginHelper;



// init app with app id (APPID) and secret (SECRET)
FacebookSession::setDefaultApplication('XXXXXXXXXX XXXXXXXX','XXXXXXXXXXXXXXXXXX');

// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper( 'XXXXXXXXXXXXX' );

try {
$session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
// When Facebook returns an error
} catch( Exception $ex ) {
// When validation fails or other local issues
}

// see if we have a session
if ( isset( $session ) ) {
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me' );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();

// print data
echo print_r( $graphObject, 1 );






if($session) {


try {


$response = (new FacebookRequest(
$session, 'POST', '/me/feed', array(
'link' => 'www.example.com',
'message' => 'User provided message'
)
))->execute()->getGraphObject();


echo "Posted with id: " . $response->getProperty('id');


} catch(FacebookRequestException $e) {


echo "Exception occured, code: " . $e->getCode();
echo " with message: " . $e->getMessage();


} 


}




} else {

$params = array(
scope => 'publish_actions'
//redirect_uri => $url
);
// show login url
echo '<a href="' . $helper->getLoginUrl($params) . '">Login</a>';
}
?>

1 个答案:

答案 0 :(得分:0)

如果您已经提交了批准,那么

publish_actions应该被Facebook批准用于您的申请facebook可能需要一周的时间才能在Facebook用户的时间线上发布故事。