【问题标题】:how to post on page's wall as app or page (not user)如何作为应用程序或页面(不是用户)在页面的墙上发布
【发布时间】:2013-11-27 10:59:09
【问题描述】:

是的,几乎有一百个与此相同的问题。我已经尝试了提供的答案并在论坛等上进行了搜索......但所有这些都对我不起作用:(。我在 facebook 上有一个应用程序。我想发布一个指向我页面时间线的链接。(不在用户的时间线上) .我怎么能用php sdk做到这一点?我发现这篇文章How do you post to the wall on a facebook page (not profile)。它的信息量很大,但我仍然不知道该怎么做。我也读到这篇文章Post to Facebook Page Wall。对我仍然没有帮助。这就是我目前有:

     require_once('libs/facebook.php');
    $facebook = new Facebook(array(
        'appId' => 'xxxxxxxxxxxxxxxxxx',
        'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    ));

    $attachment = array(
        'link' => $post_link,
        'message' => 'Another Super Story!',
        'actions' => array(
            array(
                'link' => $post_link
            )
        )
    );

    $result = $facebook->api('/me/feed/', 'post', $attachment);

我看到了这段代码,但我不知道数字代表什么

$facebook->api('/123456789/feed', 'post', array( 'access_token' => $token, 'link' => 'http://www.example.com' ));

请帮助我。我急于解决我的问题。我不知道该怎么办。提前谢谢你。

编辑: 我现在有了这个代码,因为我提到了这个问题Facebook API: How to post to my own wall page?。但仍然不适合我。谁能告诉我我错过了什么?

    $page_access_token = "2xxxxxxxxxxxx|bxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
                $result = $facebook->api("/me/accounts");
                foreach($result["data"] as $page) {
                    if($page["id"] == $page_id) {
                        //$page_access_token = $page["access_token"];
                        $page_access_token = $facebook->api("/".FB_PAGE_ID."?fields=access_token");
                        break;
                    }
                }
    $attachment = array(
    'message' => $post_msg,
    'link' => $post_link,
    'access_token' => $page_access_token,
    );
    $facebook->api("/".FB_PAGE_ID.'/feed', 'POST', $attachment);

【问题讨论】:

    标签: php facebook facebook-graph-api


    【解决方案1】:

    在使用 facebook api 方法之前,您需要获取访问令牌。可能这个例子对你有用https://github.com/facebook/facebook-php-sdk/blob/master/examples/example.php

    【讨论】:

    • 感谢您的回答。我一直在等待有人回答我。我试过那个。但它会发布到用户的时间线。我需要做的是让我的 paga/app 在页面本身上发布。如何获取我的页面的访问令牌?感谢您进一步帮助我
    猜你喜欢
    • 2012-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-13
    • 2011-07-05
    • 1970-01-01
    • 2012-10-11
    相关资源
    最近更新 更多