【问题标题】:Using Prime31 and Facebook GraphAPI to upload a Photo on a Facebook-Page使用 Prime M31 和 Facebook Graph API 在 Facebook 页面上上传照片
【发布时间】:2013-11-08 14:36:59
【问题描述】:

使用 Prime31 我可以成功地将图像上传到我自己的墙上调用

public void postPhoto(byte[] photoBytes){
    Facebook.instance.postImage( photoBytes, "my message", completionHandlerUploadPhoto );
}

但现在我想将同一张图片发布到 Facebook 页面的相册中。我试着调用我写的这个函数:

public void postToFatFishPage(byte[] photoBytes){
    Dictionary<string, object> arguments = new Dictionary<string, object>();
    arguments.Add("access_token", FacebookAndroid.getAccessToken());
    arguments.Add("message", "my message");
    arguments.Add("image", photoBytes);

    Facebook.instance.graphRequest("/"+facebookPageID+"/photos", HTTPVerb.POST, arguments, ( string error, object obj ) =>
    {
        Debug.Log ("In Callback postToFatFishPage");
        // if we have an error we dont proceed any further
        if( error != null ){
            Debug.Log("Error posting Photo to FatFish FB-Page: " + error);
            return; 
        }
        Debug.Log("No error");          
    });
}

回调函数说没有错误,但我发布到的 Facebook 页面说没有上传图片导致错误。

我使用以下权限登录:

FacebookAndroid.loginWithPublishPermissions( new string[] { "email", "user_birthday" } );

也许我必须添加更多权限?

希望有人可以帮助我!

编辑

我还尝试使用album_id 而不是page_id,但两者都不起作用。 仍然没有错误...我打印出回调的字典:

{
    [id] = <some long number>,
    [post_id] = <some even longer number with a underline in center>,
}

【问题讨论】:

    标签: facebook facebook-graph-api unity3d prime31


    【解决方案1】:

    我不知道我到底做了什么,但知道它在神奇地工作......(星期一......)

    这就是函数:

    public void postToFatFishPage(byte[] photoBytes){
        Dictionary<string, object> arguments = new Dictionary<string, object>();
        arguments.Add("access_token", FacebookAndroid.getAccessToken());
        arguments.Add("message, myMessage);
        arguments.Add("image", photoBytes);
    
        Facebook.instance.graphRequest("/"+pageID+"/photos/", HTTPVerb.POST, arguments, ( string error, object obj ) =>
        {
            // if we have an error we dont proceed any further
            if( error != null ){
                Debug.Log("Error posting Photo to FatFish FB-Page: " + error);
                return; 
            }
    
            Debug.Log("SUCCESS!");
    
        });
    }
    

    我希望有人可以帮助我:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-21
      • 2011-06-27
      • 2011-12-12
      • 1970-01-01
      相关资源
      最近更新 更多