我需要編寫將發送鏈接到Facebook粉絲頁牆的應用程序。
我使用PHP SDK v3。有一個例子如何發佈的東西:如何在Facebook上共享外部鏈接或URL
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'XXXX',
'secret' => 'YYYYYYYYYY',
'cookie' => true,
));
$fbsession = $facebook->getSession();
if ($fbsession) {
$attachment = array(
'message' => 'this is my message',
'name' => 'This is my demo Facebook application!',
'caption' => "Caption of the Post",
'link' => 'http://www.lycos.com',
'description' => 'Test de post depuis application PHP',
'picture' => 'http://www.lalibre.be/img/logoLaLibre.gif',
'actions' => array(array('name' => 'Get Search',
'link' => 'http://www.google.com'))
);
$result = $facebook->api('/USER_WALL/feed/','post',$attachment);
}
它工作正常。問題是我要發佈只是一個普通的Facebook鏈接(帶鏈接圖標,無需申請名稱和共享按鈕)
是這樣的:
$result = $facebook->api('/USER_WALL/feed/','link',$attachment);
gives me an error (Fatal error: Uncaught Exception: Unsupported method, link thrown in /home/.../src/base_facebook.php on line 959)
任何想法如何做到這一點? 我發現了兩個鏈接FB文檔:
- http://developers.facebook.com/docs/reference/rest/links.post/
- http://developers.facebook.com/docs/reference/api/link/
,但我仍然不知道在PHP-SDK V3使用本
- http://developers.facebook.com/docs/reference/rest/links.post/
- http://developers.facebook.com/docs/reference/api/link/
可以複製/粘貼我的代碼你的時候請檢索access_toekn嗎?謝謝 – scraly 2011-06-01 08:42:26
使用此鏈接設置權限: 'https://graph.facebook.com/oauth/authorize?client_id=APP_ID&scope=publish_stream,offline_access,read_stream,manage_pages&redirect_uri=http://www.facebook.com/connect/login_success。它將返回代碼,在下一個鏈接中使用它: 'https://graph.facebook.com/oauth/access_token?client_id=APP_ID&redirect_uri=http://www.facebook.com/connect/login_success.html&client_secret = APP_SECRET&code = CODE' 它會返回access_token – Erroid 2011-06-01 12:10:09