イベントや何かについて、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 個のアクセス トークンが必要ですが、アプリケーションから投稿する場合、アプリケーション トークンは一度にすべてのユーザーのウォールに投稿するために使用されるため、アプリケーションの単一のアクセス トークンを使用して投稿できます。あなたのアプリがそれを持っていれば、百万人のユーザーに。このリンクを使用してアプリケーションのアクセストークンを取得する方法
https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=xxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxx
その後、配列内のすべてのIDを取得し、同じコードを実行して、forループを使用してすべてのユーザーウォールに投稿するか、とにかく使用したコードを提供します。
<?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++;
}
?>