我的问题很简单。如何发布自动收报机和活动最近但不在墙上(时间轴)与PHP。 (发布一个动作)。 我已经在javascript中完成了但我想在php中
我测试了这个:
$params = array(
'message' => "This post is a test",
'name' => "Titre de mon test",
'caption' => "My Caption",
'description' => "Some Description...",
'link' => "http://stackoverflow.com",
'actions' => array('name'=>'Recipe','link'=>'url'),
'picture' => "http://i.imgur.com/VUBz8.png",
);
$post = $facebook->api("/$user/feed","POST",$params);
感谢。
我发现编辑:
我找到了
<meta property="og:title" content="My article" />
<meta property="og:type" content="namespace:recipe" />
<meta property="og:url" content="http://url/" />
<meta property="og:image" content="" />
<meta property="fb:app_id" content="apikey" />
<meta property="og:description" content="My wonderful article" />
和php
try {
$action = array('name' => 'recipe', 'link' => 'http://url/');
$actions = json_encode($action);
$params = array('recipe'=>'http://url/','access_token'=>$facebook->getAccessToken(), 'actions'=> urlencode($actions));
$out = $facebook->api('/me/namespace:cook','post',$params);
echo "Your post was successfully posted to UID: $user";
}
catch (FacebookApiException $e) {
$result = $e->getResult();
}
}
答案 0 :(得分:1)
要发布活动,您需要创建一个动作和对象。您需要按照http://developers.facebook.com/docs/opengraph/keyconcepts/上的说明进行操作。
您在问题中指定的PHP和JavaScript代码对于将操作发布到用户的配置文件是正确的,前提是您已请求用户的publish_actions
权限。在用户可以使用之前,该行动还需要得到Facebook的批准。
$params = array( 'recipe'=>'http://url/' );
$out = $facebook->api( '/me/namespace:cook','post', $params );
if ( $out )
echo "Activity posted";
else
echo "Post was unsuccessful";