Authenticating a FACEBOOK Application - PHP

后端 未结 3 528
耶瑟儿~
耶瑟儿~ 2021-01-16 16:41

i need to authenticate before posting to my own wall, so here is my code

function get_app_token($appid, $appsecret)
{
$args = array(
\'grant_type\' => \'c         


        
相关标签:
3条回答
  • 2021-01-16 17:15

    Value of $token is access_token=<YOUR_ACCESS_TOKEN>

    You cannot pass $token value directly to the access_token parameter.

    $token = get_app_token($appid, $appsecret);
    $access_token = split('=',$token);
    $attachment = array(
                        'message' => '',
                        'access_token' => $access_token[1],
                        'name' => 'Attachment Name',
                        'caption' => 'Attachment Caption',
                        'link' => 'http://apps.facebook.com/xxxxxx/',
                        'description' => 'Description .....',
                        'picture' => 'http://www.google.com/logo.jpg',
                        'actions' => array(array('name' => 'Action Text', 
                                  'link' => 'http://apps.facebook.com/xxxxxx/'))
                  );
    

    Hope this will helps in making that work... :)

    0 讨论(0)
  • 2021-01-16 17:18

    you can get access_token from session array of facebook object directly.

    $session = $facebook->getSession();
    $session['access_token'];
    

    of course you need to be authorized. if session is not set you must redirect to loginUrl

    $facebook->getLoginUrl(array('req_perms' => 'email,read_stream,publish_stream'));
    // this will return url for your authorization
    

    and request permission you need.

    0 讨论(0)
  • 2021-01-16 17:24

    A client_credentials access token doesn't give any access to /me (who would "me" be in this case? there's nothing that ties it to a user), let alone posting access. It is for use only with application-level Graph API calls, like to get an application's Insights data.

    0 讨论(0)
提交回复
热议问题