2014-01-21 54 views
-2

我有一個Facebook頁面臉書這個功能是否存在?

https://www.facebook.com/Best.Brain.Teasers

和我的網站

http://gpuzzles.com

我看了轉播的Facebook鏈接下方 https://developers.facebook.com/docs/plugins/comments/

的評論框讓人們對內容進行評論您的網站使用他們的Facebook個人資料並向他們的朋友展示此活動新聞提要。它還包含內置的審覈工具和特殊的社交相關性排名。

我可以鏈接我的臉書頁面和我的網站 即所有張貼在我的fb頁面牆上的評論自動在web帖子/博客中發佈。

+0

有趣的功能要求,但我真的很懷疑,如果這個功能存在[發佈至Facebook粉絲頁面飼料爲用戶槽PHP SDK]的 –

+0

可能重複(http://stackoverflow.com/questions/17020585/posting -to-Facebook的扇頁送進作爲用戶槽式-PHP-SDK) –

回答

0

是的,你可以做到這一點。

只需將以下代碼粘貼到您需要發佈的網站中。只要確保您的服務器啓用了Curl並編輯代碼以適合您的Facebook標識。由你

<ul> 
<?php 
//function to retrieve posts from facebook’s server 
function loadFB($fbID){ 
$url="http://graph.facebook.com/".$fbID."/feed?limit=3"; 
//load and setup CURL 
$c = curl_init($url); 
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); 
//get data from facebook and decode JSON 
$page = json_decode(curl_exec($c)); 
//close the connection 
curl_close($c); 
//return the data as an object 
return $page->data; 
} 

/* Change These Values */ 
// Your Facebook ID 
$fbid = "YOUR_FB_ID"; 
// How many posts to show? 
$fbLimit = 10; 
// Your Timezone 
date_default_timezone_set("America/Chicago"); 


/* Dont Change */ 
// Variable used to count how many we’ve loaded 
$fbCount = 0; 
// Call the function and get the posts from facebook 
$myPosts = loadFB($fbid); 


//loop through all the posts we got from facebook 
foreach($myPosts as $dPost){ 
//only show posts that are posted by the page admin 
if($dPost->from->id==$fbid){ 
    //get the post date/time and convert to unix time 
    $dTime = strtotime($dPost->created_time); 
    //format the date/time into something human readable 
    //if you want it formatted differently look up the php date function 
    $myTime=date("M d Y h:ia",$dTime); 
    ?> 
    <ul> 
     <li><?php echo($dPost->message) . $myTime; ?></li> 
    </ul> 
    <?php 
    //increment counter 
    $fbCount++; 
    //if we’ve outputted the number set above in fblimit we’re done 
    if($fbCount >= $fbLimit) break; 
} 
} 
?> 
</ul>