通过ActionScript发布到Facebook Wall

时间:2012-07-13 10:17:05

标签: actionscript-3 facebook-graph-api actionscript

我想在用户的墙上张贴一些东西。但是我一直收到这个错误。

  

TypeError:错误#1006:值不是函数       在com.facebook.graph.core :: AbstractFacebook / handleRequestLoad()
      在com.facebook.graph.net::AbstractFacebookRequest/dispatchComplete()
      在com.facebook.graph.net::AbstractFacebookRequest/handleDataLoad()
      在com.facebook.graph.net::AbstractFacebookRequest/handleURLLoaderComplete()
      在flash.events::EventDispatcher/dispatchEventFunction()
      在flash.events :::EventDispatcher / dispatchEvent()
      在flash.net::URLLoader/onComplete()

以下是代码:

public function PostToUserWall(userId:String, message:String, name:String, caption:String, description:String, link:String):void
    {
        var params: Object = new Object;
        params.message = message;
        params.name = name;
        params.caption = caption;
        params.description = description;
        params.link = link;
        params.picture = "www.something.com/something.png";
        Facebook.api("/"+userId+"/feed", null, params, "POST");
    }

我试图了解这个问题是什么。但不知何故无法弄明白。这里有什么帮助吗?

2 个答案:

答案 0 :(得分:1)

这只是一个挑战调试,只有一个堆栈跟踪继续。发布代码将提高某人能够帮助您的可能性。但是,在我看来,对于调用Facebook API的回调parameter不是函数。我建议你仔细检查你在API调用中传递的参数。

修改

对facebook API的调用的第二个参数应该是API在返回结果时将执行的函数。尝试更新您的代码,如下所示:

public function PostToUserWall(userId:String, message:String, name:String, caption:String, description:String, link:String):void
{
        var params: Object = new Object;
        params.message = message;
        params.name = name;
        params.caption = caption;
        params.description = description;
        params.link = link;
        params.picture = "www.something.com/something.png";
        Facebook.api("/"+userId+"/feed", resultHandler, params, "POST");
}

private function resultHandler():void
{
    trace("Result!");
}

答案 1 :(得分:0)

以下两种方法应该有效:

这张贴一张来自你的swf的位图。

public function postImageToUserWall(bmp:Bitmap, caption:String):void
{
    Facebook.api(_userID +'/photos', onPicPostedToUserWall, {message:caption, image:bmp, fileName:'file.png'}, URLRequestMethod.POST);
}

private function onPicPostedToUserWall(result:Object, fail:Object):void
{
    if (result)
    {
        //result.id is id of photo that was just posted - used to link to pic when posting to recipient's wall
    }
    else if (fail)
    {
        //
    }
}

这张照片来自链接:

public function postLinkToFeed(params:Object)
{
    Facebook.ui('feed', {   
                            name: params.name, 
                            caption: params.caption, 
                            description: params.description, 
                            picture: params.imageURL, 
                            link: params.link,
                            to: params.toID,
                            from: params.fromID
                        }, onPostToFeedComplete, 'iframe');
    }

private function onPostToFeedComplete(result:Object)
{
    //
}