2011-02-25 117 views
0

尝试后用Facebook PHP SDK的状态更新。代码如下。据我了解,我需要延长的权限,我在登录URL中使用'& scope = publish_stream',但这仍然不起作用。Facebook的API的OAuth错误时抛出#200 '&范围= publish_steam'

得到的登录URL的样子: https://www.facebook.com/login.php?api_key=174954539217971&cancel_url=http%3A%2F%2Fexample.com%2facebook.post.php&display=page&fbconnect=1&next=http%3A%2F%2Fexample.com%2Ffacebook.post.php&return_session=1&session_version=3&v=1.0&scope=publish_stream

所以你可以看到它被设置。虽然这与本质上是相同的问题:Facebook OAuthException: "user hasn't authorized the application to perform this action"

该线程中的建议解决方案在此处不起作用。

<?php 

echo "Posting to facebook..<br/>"; 

require './fb_src/facebook.php'; 

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

$session = $facebook->getSession(); 
$me = null; 
if ($session) { 
    try { 
    $uid = $facebook->getUser(); 
    $me = $facebook->api('/me'); 
    } catch (FacebookApiException $e) { 
    header('Location: ' . $facebook->getLoginUrl(array('scope' => 'publish_stream'))); 
    error_log($e); 
    } 
} 
else { 
    header('Location: ' . $facebook->getLoginUrl(array('scope' => 'publish_stream'))); 
} 

print_r($me); 

try { 
    $feed = $facebook->api('/me/feed', 'post', array('message' => 'Hello world!', 'cb' => '')); 
} catch (FacebookApiException $e) { 
    print($e); 
} 
print_r($feed); 
?> 

回答

0

参数是 'req_perms' 不是 '范围'。因此,很难找到好的文档...现在

工作正常。

+0

你确定吗?自从昨天req_perms不再工作,我改变了范围,并再次工作... wtf? – Tobias 2011-05-22 04:56:44

+0

req_perms现在适用于我。 – mkocubinski 2011-05-24 20:58:34