问题描述
您知道Facebook将其API升级到了V3.1,现在缓慢地淘汰了旧的API和应用程序,因此我们不得不迁移到新的API上,他们做出了一些艰难的决定,这些决定在SPAM网站上是好的,但对开发人员也很困难.
提醒:将于2018年10月5日弃用Graph API v2.7.请使用 API升级工具,以了解这可能会对您的应用产生什么影响.有关更多详细信息,请参见更改日志
现在,我创建了一个具有以下设置的新FB应用程序,如下面的屏幕截图所示,以在我自己的页面上发布而不是个人资料,但也出现了下面提到的错误.
然后,我使用下面的代码在我自己的页面上发布了自己的页面,该页面是我创建此应用程序的同一帐户的所有者.
<?php
$page_access_token = 'GENERAL_ACCESS_TOKEN';
$page_id = 'OWN_PAGE_ID';
// From https://developers.facebook.com/tools/explorer
$data['message'] = "Text_Message";
//$data['picture'] = "http://www.example.com/image.jpg";
//$data['link'] = "http://www.example.com/";
//$data['caption'] = "Caption";
//$data['description'] = "Description";
$data['access_token'] = $page_access_token;
$post_url = 'https://graph.facebook.com/'.$page_id.'/feed';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($ch);
echo $return;
curl_close($ch);
?>
现在,当我运行较高代码时,出现以下错误...
{"error":{"message":"(#200) Requires either publish_to_groups permission and app being installed in the group, or manage_pages and publish_pages as an admin with sufficient administrative permission","type":"OAuthException","code":200,"fbtrace_id":"XXXXXXXXX"}}
现在我的问题是从哪里可以授予我的Apps这些许可权,因为如上上一个屏幕快照所示,我所允许的所有人都没有看到这些名称(publish_to_groups
,manage_pages
和publish_pages
等)./p>
注意:我现在创建并编写了所有代码,因此我需要使用新发布的API 3.1的解决方案.
更新:
我的朋友告诉我允许所有权限使我的代码正常工作,如下面的屏幕快照所示,但我无法在我的应用程序中查看这些权限.我需要所有这些.如何获得它们?
我尝试了很多事情,然后在Facebook开发人员指南上发现它,新的更新之后,如果这些应用程序上线,则没有人可以得到以下所有显示的权限.要在启用您的应用后获得所有这些权限,您必须申请权限进行审查,否则您可以在开发模式"下免费获得所有权限,但这仅对您有效.
您知道要获得自己的应用程序中的所有权限供您自己使用,无需查看您的应用程序或任何内容即可获得它.您可以在下面看到应用程序的常规设置".
您只需要通过关闭实时模式(如以下屏幕快照和上部屏幕截图所示)即可将应用程序置于开发模式.
完成此操作后,只需转到图形API资源管理器,然后单击获取令牌"按钮然后选择获取用户访问令牌",在这里您将获得如本答案的第一个屏幕截图所示的弹出窗口,您可以在其中选择所需的范围并单击获取访问令牌".它将引发一个POPUP,需要您的许可才能允许它,然后它将返回您访问令牌. (您可以将访问令牌延长至60天)
注意:仅由于您的应用未启用,此令牌才会在您的信息页上显示,因此您的应用所做的每项活动仅适合您.
As you know that Facebook upgraded it API to V3.1 and now killing old APIs and Apps slowly so we have to migrate on there new API where they took some hard decision that is good on SPAM site but hard for developers too.
Reminder: Graph API v2.7 will be deprecated on Oct 05, 2018. Please use the API Upgrade Tool to understand how this might impact your app. For more details see the changelog
Now I created a new FB app with some settings as shown in the below screenshots to Post On My Own Pages not Profile but got errors that is mentioned below too.
And then I used the below code to post on my own page where I am Owner from same account where I created this Apps.
<?php
$page_access_token = 'GENERAL_ACCESS_TOKEN';
$page_id = 'OWN_PAGE_ID';
// From https://developers.facebook.com/tools/explorer
$data['message'] = "Text_Message";
//$data['picture'] = "http://www.example.com/image.jpg";
//$data['link'] = "http://www.example.com/";
//$data['caption'] = "Caption";
//$data['description'] = "Description";
$data['access_token'] = $page_access_token;
$post_url = 'https://graph.facebook.com/'.$page_id.'/feed';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($ch);
echo $return;
curl_close($ch);
?>
Now when I run upper code, I got the below error...
{"error":{"message":"(#200) Requires either publish_to_groups permission and app being installed in the group, or manage_pages and publish_pages as an admin with sufficient administrative permission","type":"OAuthException","code":200,"fbtrace_id":"XXXXXXXXX"}}
Now my question is from where I can allow my Apps these permission because where I allowed all didn't see these names (publish_to_groups
, manage_pages
and publish_pages
etc) as shown in the above last screenshot.
Note: Everything I created and Code now so I need solution working with newly released API 3.1.
UPDATE:
My friend told me to allow all permission to get my code working as shown in the below screenshot but I am not able to view these permission in my apps. I need all these. How to get them?
I tried many things and then I found it on Facebook Developers Guide that after new Update, No one can get all of the below showed permission if the Apps goes Live. To get all these permission after making your Apps live, you have to Apply for permissions to review or else you can get all permission freely in Development Mode But it will work for you only.
As you know that to get all permissions in your Apps for your own use, you can get it without Reviewing your apps or anything. You can see a General Setting of an Apps below.
You just have to turn your apps in development mode by turning the live mode off as shown in the below and upper screenshots.
After doing this, just go to Graph API Explorer and click "Get Token" button then select "Get User Access Token" and here you will get the pop up as shown in the first screenshot of this Answer where you can select your desired scopes and click "Get Access Token". It will raise a POPUP where it will need your permission to allow and then it will return you the Access Token. (You Can Extend Your Access Token To 60 Days)
Note: This token will post on your Page will be visible to you only because your Apps is not live so every activity done by your apps is for you only.
这篇关于针对开发人员的Facebook Graph API v3.1访问令牌权限限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!