改变Facebook Unity SDK中的CurrentAccessToken [英] Changing CurrentAccessToken in Facebook Unity SDK
问题描述
我正在使用iOS上运行的Unity Facebook SDK发布到Facebook页面。据我所知,为了做到这一点,我需要使用 manage_pages
和 publish_pages
的页面访问令牌。我知道我可以从 / me / accounts?fields = access_token
得到它,但是如何告诉 AccessToken.CurrentAccessToken
使用我的页面访问令牌?
I'm trying to post to a Facebook page AS the page using the Unity Facebook SDK running on iOS. As I understand, to do that, I need the pages access token with manage_pages
and publish_pages
. I know that I can get it from /me/accounts?fields=access_token
, but how do I tell AccessToken.CurrentAccessToken
to use my pages access token instead?
现在我正在使用以下内容:
Right now i'm using the following:
var wwwForm = new WWWForm();
//wwwForm.AddField ("access_token", "A-T I NEED");
wwwForm.AddBinaryData("image", screenshot, "InteractiveConsole.png");
wwwForm.AddField("message", "herp derp. I did a thing! Did I do this right?");
FB.API("/PAGE-ID/photos", HttpMethod.POST, HandleResult, wwwForm);
我尝试手动放置访问令牌,但没有工作(所以我评论了)
I tried putting the access token manually, but that didn't work (so I commented it out).
有了这个,因为它是一个错误,告诉我,我需要 publish_actions
,这是不正确,因为我不想以用户身份发布。如果我也得到 publish_actions
邮政上线,而是以用户的身份发布到该页面。 (用户也是管理员)
With this as it is I'm getting an error, telling me that I need publish_actions
, wich is not correct since I'm not trying to post as the user. If I also get publish_actions
the Post goes online, but is posted to the page as the user speaking. (User is also Admin)
任何想法?谢谢!
推荐答案
所以,我向Facebook提交了一个错误报告,事实证明:...在这个时候这个功能是不支持。这意味着现在可以使用您通过 FB.API
在 FB.API
。他们不会在文档中告诉你。
So, I filed a bug report to facebook and as it turns out: "… at this time this functionality is not supported." Wich simply means there is now way to use the Page Access Token you acquired via the FB.API
within the FB.API
. And they are not going to tell you abot it in the documentation.
作为一种解决方法,我只需使用一个 UnityWebRequest
像这样:
As a workaround I simply use a UnityWebRequest
like this:
IEnumerator UploadToPage(byte[] screenshot) {
var wwwForm = new WWWForm();
wwwForm.AddField("message", "herp derp. I did a thing! Did I do this right?");
wwwForm.AddBinaryData("image", screenshot, "Test.png");
string url = "https" + "://graph.facebook.com/"+ PageID + "/photos";
url += "?access_token=" + PageAccessToken;
using (UnityWebRequest www = UnityWebRequest.Post(url, wwwForm))
{
yield return www.Send();
if (www.isError)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Form upload complete!");
}
}
Debug.Log(url);
}
这篇关于改变Facebook Unity SDK中的CurrentAccessToken的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!