How do I ask for facebook permissions in PHP?

后端 未结 3 1730
借酒劲吻你
借酒劲吻你 2021-01-07 07:36

How do I ask for facebook permissions in PHP? can you please give me an example?

thanks.

3条回答
  •  猫巷女王i
    2021-01-07 08:10

    Assuming you have the user's access_token(which you can get via $facebook->getAccessToken() after you've logged a user in:

    try{
        $permissions = $facebook->api('/me/permissions', 'get', array('access_token'=>$access_token));
        print_r($permissions, true);
        if(empty($permissions['data'][0]['installed'])){
            echo 'User has not installed the application.';
        }
        if(empty($permissions['data'][0]['publish_stream'])){
            echo 'User does not have the publish_stream permission.';
        }
    }catch(Exception $e){
        echo $e->getMessage();
    }
    

提交回复
热议问题