[英]Changing CurrentAccessToken in Facebook Unity SDK
I'm trying to post to a Facebook page AS the page using the Unity Facebook SDK running on iOS. 我正在尝试使用iOS上运行的Unity Facebook SDK将Facebook页面作为页面发布到Facebook页面。 As I understand, to do that, I need the pages access token with manage_pages
and publish_pages
. 据我了解,要做到这一点,我需要页面访问令牌具有manage_pages
和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? 我知道可以从/me/accounts?fields=access_token
获取它,但是如何告诉AccessToken.CurrentAccessToken
使用页面访问令牌呢?
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). 我尝试手动放置访问令牌,但这没有用(因此我将其注释掉了)。
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. 有了这个,我收到一个错误,告诉我我需要publish_actions
,这不正确,因为我没有尝试以用户身份发布。 If I also get publish_actions
the Post goes online, but is posted to the page as the user speaking. 如果我还得到publish_actions
该帖子会联机,但会以用户讲话的形式发布到页面上。 (User is also Admin) (用户也是管理员)
Any Ideas ? 有任何想法吗 ? Thanks! 谢谢!
So, I filed a bug report to facebook and as it turns out: "… at this time this functionality is not supported." 因此,我向Facebook提交了一个错误报告,结果是:“……目前不支持此功能。” Wich simply means there is now way to use the Page Access Token you acquired via the FB.API
within the FB.API
. 至极只是意味着现在有办法使用您通过获取的页面访问令牌FB.API
的内FB.API
。 And they are not going to tell you abot it in the documentation. 他们不会在文档中告诉您。
As a workaround I simply use a UnityWebRequest
like this: 作为解决方法,我仅使用UnityWebRequest
如下所示:
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.