1

重複の可能性:
FacebookGraphApi-管理者としてファンページに投稿

自分のサイトにブログ投稿を送信して、同じブログ投稿をFacebookの自分のページに送信できるフォームを作成しようとしています。

私のページは次のとおりです:https ://www.facebook.com/foreveraloneminecraft

ログインして手動で投稿したかのように投稿したい(他のすべての投稿と同様)。

私はあちこちを検索してきましたが、見つけたものはすべて、実際に何かを投稿したり、エラーをスローしたりすることはありません。

これは私がすべてを検索した後にこれまでに得たものです:

<?php
include('core/init.inc.php');
require_once('libs/parser.php'); // path to Recruiting Parsers' file
$parser = new parser; //  start up Recruiting Parsers

if(isset($_POST['submit'], $_POST['user'], $_POST['title'], $_POST['body'])
{
    //--- Facebook Posting ------
    require_once('libs/facebook/facebook.php');
    $appid = '286964398044671';
    $appsecret = 'myappsecret';
    $pageid = '215852885143861';
    $token = 'mytoken';

    // Create our Application instance (replace this with your appId and secret).
    $facebook = new Facebook(array(
      'appId'  => $appid,
      'secret' => $appsecret,
    ));

    // Get the current access token
    //$token = $facebook->getAccessToken();

    //Information that makes up the facebook page post
    $attachment = array(
            'access_token' => $token,
            'message' => $_POST['body'], 
            'link'    => 'http://hgs1957.hostedd.com/news.php',
            'picture' => 'http://hgs1957.hostedd.com/images/foreverAloneMCguy.png',
            'name'    => $_POST['title'],
            'description'=> 'Latest news for foreveralonemc.com.'
    );

    //Try to post to the facebook page
    try{
    $res = $facebook->api('/'.$pageid.'/feed','POST',$attachment);

    } catch (Exception $e){

        echo $e->getMessage();
    }

    //Add the post to the sql database of posts
    //add_post($_POST['user'], $_POST['title'], $_POST['body']);

    //Redirect to news feed
    header('Location: news.php');
    die();
}
?>

トークンからappsecretを使用したのは、https://developers.facebook.com/tools/explorer/を次の権限で使用したときに取得したものです:publish_stream、status_update、manage_pages、publish_actions、offline_access試してみると、ページに投稿されているようです壁ですが、私としてはページや管理者としてではありません。

これが単なるバグなのか、それとも私が間違っているのかを誰かが知っていますか?

4

1 に答える 1

1

有効期限が切れた後に新しいアクセス トークンを更新して保存するには、アプリに再度ログインする必要があります。これがお役に立てば幸いです。

于 2012-12-15T12:21:51.563 に答える