简体   繁体   English

php(#200)用户未授权应用程序执行此操作

[英]php (#200) The user hasn't authorized the application to perform this action

what should i do to fix this problem this is my code i am using facebook graph API to do it require_once("src/facebook.php"); 我应该怎么解决这个问题,这是我的代码,我正在使用facebook graph API来做到这一点require_once(“ src / facebook.php”); // set the right path //设置正确的路径

    $config = array();
    $config['appId'] = '000000000000000';
    $config['secret'] = '0000000000000000000000';
    $config['fileUpload'] = false; // optional
    // $config['publish_actions'] = true;
    $fb = new Facebook($config);

    $params = array(
      // this is the access token for Fan Page
      "access_token" => "--------------------- my access token --------------------------",
      "message" => "Here is a blog post about auto posting on Facebook using PHP #php #facebook",
      "link" => "http://www.pontikis.net/blog/auto_post_on_facebook_with_php",
      "picture" => "http://i.imgur.com/lHkOsiH.png ",
      "name" => "How to Auto Post on Facebook with PHP",
      "caption" => "www.pontikis.net",
      "description" => "Automatically post on Facebook with PHP using Facebook PHP SDK. How to create a Facebook app. Obtain and extend Facebook access tokens. Cron automation."
    );

    try {
      // 466400200079875 is Facebook id of Fan page https://www.facebook.com/pontikis.net 
      $ret = $fb->api('/417648154966881/feed', 'POST', $params);
      echo 'Successfully posted to Facebook Fan Page';
    } catch(Exception $e) {
      echo $e->getMessage();
    }

I have a code with request permission from user... I hope this help.You have use old version with facebook api, I will update preference soon 我有一个具有用户请求权限的代码...希望有帮助。您已将旧版本与facebook api结合使用,我将尽快更新偏好

require 'src/facebook.php';
        $config = array('appId' => '000000', 'secret' => '000000', );
        $facebook = new Facebook($config);
        try
        {
            $user_id = $facebook -> getUser();
            if($user_id){
                $user_profile = $facebook->api('/me','GET');
            }else {
                      $login_Url = $facebook -> getLoginUrl(array('canvas' => 1, 'fbconnect' => 0, 'scope' => 'user_about_me,user_activities,user_status,read_stream,publish_stream,photo_upload,status_update,publish_actions','redirect_uri' => 'https://yoururl.com/'));
                      exit("<script>window.top.location.replace('$login_Url');</script>");
            }
        }catch(exception $e){
            /
            exit("<script>location.reload();</script>");
    }

update 更新

URL Preference: https://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/ URL首选项: https : //developers.facebook.com/docs/reference/php/facebook-getLoginUrl/

The error message means that you did not authorize the user with the publish_actions permission, or you did not authorize the user at all . 该错误消息表示您未授权用户使用publish_actions权限,或者您根本没有授权用户

About authorization, check out this page in the Facebook docs: https://developers.facebook.com/docs/php/gettingstarted/4.0.0 关于授权,请在Facebook文档中查看以下页面: https : //developers.facebook.com/docs/php/gettingstarted/4.0.0

Keep in mind that you need a "Page Access Token" to post "as Page", this is explained very well in the following articles: 请记住,您需要一个“页面访问令牌”来发布“作为页面”,以下文章对此进行了很好的解释:

Basically, you need to authorize a user with publish_actions AND manage_pages and call /me/accounts with the API to get Page Tokens for all the Pages of the user. 基本上,您需要使用publish_actionsmanage_pages授权用户,并使用API​​调用/me/accounts以获得该用户所有页面的页面令牌。

...and then there is " Login Review " . ...然后有登录评论 Those permissions will only work for users with a role in the App (Admin/Developer/Tester). 这些权限仅对在App(Admin / Developer / Tester)中具有角色的用户有效。 You need to go through a review process with them before you can release your App to the public. 您需要先与他们进行审核,然后才能向公众发布您的应用。

Of course you have to do the programming part on your own. 当然,您必须自己完成编程部分。 It´s not that hard though :) 虽然不难:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 (#200)用户未授权应用程序执行此操作 - (#200) The user hasn't authorized the application to perform this action NativeFirebaseError:[存储/未授权] 用户无权执行所需的操作 - NativeFirebaseError: [storage/unauthorized] User is not authorized to perform the desired action 通过API执行用户操作 - Perform user action via API php按钮无法执行操作 - not work php button to perform the action stringByEvaluatingJavaScriptFromString不执行操作 - stringByEvaluatingJavaScriptFromString doesn't perform action 如何在用户重新加载页面或退出我的 vuejs 应用程序之前执行操作 - How to perform an action before user reload page or exit my vuejs application input [type =“ file”]确定用户是否尚未选择任何文件 - input[type=“file”] Determining if user hasn't chosen any files MissingSchema错误:尚未为模型“ User”注册架构 - MissingSchema Error: Schema hasn't been registered for model “User” 如果用户5秒钟没有滚动,如何平滑滚动到锚点? - How to smooth scroll to an anchor if a user hasn't scrolled in 5 seconds? 如果用户没有更改任何内容,如何使用它的 defaultValue 保存 TextInput? - How to save TextInput with it's defaultValue if the user hasn't changed anything?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM