自动发布Facebook粉丝页面,粉丝页面名称为PHP SDK 3.2.2

时间:2013-07-14 13:04:14

标签: facebook post

我已经在我的脸书粉丝网页上使用此代码进行自动发布

<?php

// Requires Facebook PHP SDK 3.0.1: https://github.com/facebook/php-sdk/
require ('facebook.php');

define('FACEBOOK_APP_ID',"YOUR-APP-ID");
define('FACEBOOK_SECRET',"YOUR-APP-API-SECRET");

$user = null;

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

$user = $facebook->getUser(); // Get the UID of the connected user, or 0 if the Facebook user is not connected.

if($user == 0) {

    /**
     * Get a Login URL for use with redirects. By default, full page redirect is
     * assumed. If you are using the generated URL with a window.open() call in
     * JavaScript, you can pass in display=popup as part of the $params.
     * 
     * The parameters:
     * - redirect_uri: the url to go to after a successful login
     * - scope: comma separated list of requested extended perms
     */

    $login_url = $facebook->getLoginUrl($params = array('scope' => "publish_stream"));

    echo ("<script> top.location.href='".$login_url."'</script>");

} else {

    try {
            $params = array(
                'message'       =>  "Hurray! This works :)",
                'name'          =>  "This is my title",
                'caption'       =>  "My Caption",
                'description'   =>  "Some Description...",
                'link'          =>  "http://stackoverflow.com",
                'picture'       =>  "http://i.imgur.com/VUBz8.png",
            );

            $post = $facebook->api("/$user/feed","POST",$params);

            echo "Your post was successfully posted to UID: $user";

        }
        catch (FacebookApiException $e) {
           $result = $e->getResult();
        }

}

?>

但是我需要在我的脸书粉丝页面上发布我的粉丝页面名称,这个scrpit工作非常好,但这个代码在我的粉丝页面上发布了我的管理员帐户,而不是我的粉丝页面。

PLZ帮助我:(

2 个答案:

答案 0 :(得分:0)

我认为你需要仔细看看这个article ,我是按照那里提到的步骤做的。

答案 1 :(得分:-1)

把你的标记放在这里:

https://graph.facebook.com/me/accounts?access_token=token

然后您将找到用于发布为页面的访问令牌。

希望有所帮助。