2011-10-25 35 views
-1

我已經看過開發者的頁面,但有噸噸的東西。應用程序身份驗證(我的PHP會調用應用程序嗎?),設置權限,如何在身份驗證後發佈帖子,在哪裏存儲身份驗證?等等等等等等,我無法全面瞭解他們的全部含義,以及所有這些東西需要什麼。如何在Facebook的社區頁面(作爲頁面的所有者)製作牆貼?

我只想將牆貼作爲社區/粉絲頁面發佈到社區/粉絲頁面的牆上。我的PHP應用程序應該遵循什麼步驟來製作牆貼?

+0

可能的重複[張貼在Facebook牆上的頁面,而不是用戶](http://facebook.stackoverflow.com/questions/5326537/post-on-a-facebook-wall-as-page-not-as-用戶) – Igy

回答

1

我寫了一個深入的教程關於這個主題:How To: Post On Facebook Page As Page Not As Admin User Using PHP-SDK

簡而言之:

  1. 你至少需要publish_streammanage_pagespermissions
  2. 查詢您page對象來獲取頁面訪問令牌
  3. 併發布!

從我的教程的起始代碼:

<?php 
// This code is just a snippet of the example.php script 
// from the PHP-SDK <http://github.com/facebook/php-sdk/blob/master/examples/example.php> 
require '../src/facebook.php'; 

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

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

if ($user) { 
    try { 
    $page_id = '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'  => "I'm a Page!" 
     ); 
     $post_id = $facebook->api("/$page_id/feed","post",$args); 
    } 
    } catch (FacebookApiException $e) { 
    error_log($e); 
    $user = null; 
    } 
} 

// Login or logout url will be needed depending on current user state. 
if ($user) { 
    $logoutUrl = $facebook->getLogoutUrl(); 
} else { 
    $loginUrl = $facebook->getLoginUrl(array('scope'=>'manage_pages,publish_stream')); 
} 
?> 

注:您可能需要offline_access如果要發佈,而你沒有連接到Facebook的(如:從您的CMS)

相關問題