沒有辦法直接張貼到用戶的牆使用Facebook應用程序關於任何事件或什麼的,這就是爲什麼回答我的問題。 Facebook的權限publish_stream是必不可少的這個工作。/
您需要時,他們使用你的應用程序就像在我的代碼
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxx',
));
$args = array(
'message' => 'Your Message to user Wall',
'link' => 'http://apps.facebook.com/lxxxxxxxx',
'caption' => ' Use this Awesome application or Like this Page.',
'picture' => 'http://xxxxx.png',
);
$post_id = $facebook->api("/me/feed", "post", $args);
define('db_user','username);
define('db_password','password');
define('db_host','localhost');
define('db_name','database name');
// Connect to MySQL
$dbc = @mysql_connect (db_host, db_user, db_password) OR die ('Could not connect to MySQL: ' . mysql_error());
// Select the correct database
mysql_select_db (db_name) OR die ('Could not select the database: ' . mysql_error());
$me = $facebook->api('/me');
$dbcheck = mysql_query("SELECT * FROM users WHERE oauth_provider = 'facebook' AND oauth_uid = ". $me['id']);
$dbr = mysql_fetch_array($dbcheck);
if(empty($dbr)){
$db=mysql_query("INSERT INTO users (oauth_provider, oauth_uid, username) VALUES ('facebook', {$me['id']}, '{$me['name']}') ");
}
SO張貼我的原始代碼以詳細告訴你創建用戶的數據庫。
這是人員第一次打開你的應用程序時的代碼,這個$ args被髮布到用戶牆上,id和用戶名被存儲到數據庫中。
因此,如果您希望發佈給正在使用您的應用程序的用戶牆上的任何內容,並且也授予了許可權,您可以這樣做。您可以像推廣網站或Facebook粉絲頁那樣做。
最後這是怎麼發生的。正如馬丁先生所說,我們需要10個訪問令牌給10個用戶,但如果您從應用程序發佈而不是正確的應用程序,則應用程序令牌不能正確發佈,所以使用Application的單個訪問令牌可以發佈如果您的應用程序具有該功能那麼如何使用這個鏈接
https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=xxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxx
之後得到應用的訪問令牌獲取在陣列中的所有ID和,還是要執行相同的代碼使用循環張貼在所有用戶牆上還我給我的代碼,我使用。
<?php
require_once("fb/facebook.php");
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxx',
));
$x=array("100001944919003","100000968648478","100001672538252","100003924282886");
$y=0;
while($y<=3){
$posting_fbid=$x[$y];
$attachment = array
(
'access_token'=>'access token from the url from the graph api',
'message' => 'This Page is awesome.',
'name' => 'DailyJokes-Must Like It',
'caption' => 'Dailyjokes',
'link' => 'http://facebook.com/wtfdailyjokes/',
'description' => 'Awesome Picture',
'scope' => 'publish_stream',
'picture' => 'https://www.facebook.com/photo.php?fbid=264680606974256&set=a.206648236110827.41772.206637039445280&type=1&relevant_count=1'
);
$result = $facebook->api($posting_fbid.'/feed/','post',$attachment);
echo 'successful for id '.$posting_fbid.'<br>';
$y++;
}
?>
我不確定你想要做什麼。你只是想張貼到你的Facebook應用程序的每個用戶的飼料? – 2012-08-01 17:43:33
是這就是我想要的,是可能的,或者我應該做一個單獨的數據庫來存儲他們的ID。 – Abhishek 2012-08-01 17:45:58
如果您爲每個驗證您的應用的人存儲訪問令牌,那麼您可以使用該令牌,因爲解碼時包含用戶的ID。所以你可以對所有的訪問令牌做一個'foreach()',並且做你的API調用來發布到那個用戶的牆上。 – 2012-08-01 18:37:53