0

第一次涉足facebook图表,所以如果修复有点容易,请原谅我的问题......

我已经制作了我的应用程序,得到了我所有的 appID 和秘密,并且我正在尝试作为页面发布到页面。我已授予应用程序权限,并进行了一些调试,但是在 $facebook->api 调用之后,它什么也没做...

我的代码如下:

<?php
require 'core/components/facebook/facebook.php';

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

// Get User ID
$user = $facebook->getUser();

if ($user) {
    try {
            $page_id = '****';
            $page_info = $facebook->api("/$page_id?fields=access_token");
            if( !empty($page_info['access_token']) ) {
                $args = array(
                        'access_token'  => $page_info['access_token'],
                        'message'       => "Testing"
                );
            //An echo of $page_info['access_token'] gives me an access token...
                $post_id = $facebook->api("/100160870061728/feed", "post", $args);
                //Does not echo below - help!
            echo "Success post id = " . $post_id;
            }
        else {
                $permissions = $facebook->api("/me/permissions");
                if( !array_key_exists('publish_stream', $permissions['data'][0]) || !array_key_exists('manage_pages', $permissions['data'][0])) {
                        header("Location: " . $facebook->getLoginUrl(array("scope" => "publish_stream, manage_pages")));
                }
            }
    } 
    catch (FacebookApiException $e) {
            error_log($e);
            $user = null;
    }
}

if ($user) {
    $logoutUrl = $facebook->getLogoutUrl();
} 
else {
    $loginUrl = $facebook->getLoginUrl(array('scope' => 'manage_pages, publish_stream'));
}

?>

提前谢谢了

4

0 回答 0