使用publish_stream权限将自定义操作发布到时间轴?

时间:2013-03-26 04:48:38

标签: facebook facebook-graph-api facebook-php-sdk

我正在尝试以下操作将自定义操作发布到我的时间轴上。使用Graph API Explorer已经实现了相同的效果。

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

    if($access_token != "") 
    {
        $user = $facebook->getUser();

        if($user != 0)
        {
            $queries = array(array("method" => "POST", "relative_url" => "/me/namespace:action?object=http://www.mysite.com/url/parameters"));

            try 
            {
                $postResponseA = $facebook->api("?batch=".json_encode($queries), "POST");
            } catch (FacebookApiException $e) 
            {
                echo 'AF error: '.$e;
            }
        }
    }

不会抛出任何错误。什么都没发布。

print_r($ postResponseA)显示以下内容:

Array ( [0] => Array ( [code] => 400 [headers] => Array ( [0] => Array ( [name] => Access-Control-Allow-Origin [value] => * ) [1] => Array ( [name] => Cache-Control [value] => no-store ) [2] => Array ( [name] => Connection [value] => close ) [3] => Array ( [name] => Content-Type [value] => text/javascript; charset=UTF-8 ) [4] => Array ( [name] => Expires [value] => Sat, 01 Jan 2000 00:00:00 GMT ) [5] => Array ( [name] => Pragma [value] => no-cache ) [6] => Array ( [name] => WWW-Authenticate [value] => OAuth "Facebook Platform" "invalid_request" "An active access token must be used to query information about the current user." ) ) [body] => {"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}} ) ) 

0 个答案:

没有答案