通过Facebook ActionScript 3 SDK发布在朋友的墙上
题
我绝对是编程的,只是设法学习ActionScript 3.现在,我想学习如何通过AS3 SDK使用UI类(取自一个很好的教程):
这是我在自己的墙上发布的方式:
protected function newsFeed ():void
{
// define your caption text
var theCaption:String = "CaptionText";
// define the descrition text
var theDescription:String = "Text for game Achievement";
// We need to follow the FB docs to tell it what sort of input we are sending to FB
// We are trying to set the 'feed'
var methodInput:String = 'feed';
var thePicture:String = "mylink/picture.png";
var theLink:String = "mylink";
var theName:String = "Name of FB Status Setter";
// Create an object that we'll call 'data' and fill it with the actual data we're sending to Facebook
var data:Object = {
caption:theCaption,
description:theDescription,
picture:thePicture,
name:theName,
link:theLink
};
Facebook.ui(methodInput, data, onUICallback);
}
protected function onUICallback(result:Object):void
{
// do something
}
.
这完全可以很好。我知道我必须将参数集成“到”某处。但我不知道在哪里以及如何。对不起,我非常陌生。这是来自Facebook文档
属性
from:用户发布消息的用户名或用户名。如果这是未指定的,则它默认为当前用户。如果指定,则必须是用户管理的用户的ID。
to:本故事将发布到的配置文件的ID或用户名。如果此>未指定,则默认为“从”的值“。
希望有人可以帮助我。
最好的问候, 阿米尔 P.S .:有没有办法在几个朋友的墙上发布一个朋友的墙壁和另一种邮寄方式?
解决方案
我相信您想要使用Facebook.api()
而不是'UI'。根据AS3 FB API的文档,“UI”仅打开共享对话框。如果您想在朋友墙上创建帖子,那么您将想要使用“API”。
我在flash中没有测试过这个,但我认为你可以将方法设置为/PROFILE_ID/feed
...当然用朋友的fb uid替换“profile_id”。然后,包括参数; 消息,图片,链接,名称,标题,描述和源在您的数据对象中。
所以你的代码看起来像:
.
var method:String = "/friend_id/feed";
var data:Object = {};
data.message = "Your message";
data.picture = "http://www.google.com/kittens.jpg";
data.link = "http://www.mysite.com/link";
data.caption = "Your caption";
data.description = "Your description";
data.source = "http://www.mysite.com/video.swf";//(optional) source is a video or Flash SWF
Facebook.api(method, yourCallback, data, "POST");
function yourCallback(result:Object, fail:Object):void {
if (result) {
trace(result)
} else if (fail) {
trace(fail);
}
}
如果您有多个朋友,则可能只需将UID放入阵列和循环通过上面的方法。 AS3 API具有我没有尝试的批处理方法,但您可以查看文档。
Facebook有一些非常有用的工具有些隐藏。
结帐他们的调试器及其图形API Explorer
希望这有用。