2011-02-25 93 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