F
F
FootWork2014-11-19 17:50:09
Facebook
FootWork, 2014-11-19 17:50:09

How to use FacebookRequest (facebook api)?

I understand with fb api, I want to make a post on the wall to myself and to the group.
in their documentation, everything is so simple and clear if you send everything with such requests:
https://developers.facebook.com/docs/php/FacebookR...
or there is a subsection publishing
https://developers.facebook.com/ docs/graph-api/usi...
it's not clear how to move on to handling these requests, tell me.

<?php

$url = 'https://www.facebook.com/dialog/oauth';
$params = array(
    'client_id'     => $fb_client_id,
    'redirect_uri'  => $fb_redirect_url,
    'response_type' => 'code',
    'scope'         => 'email,user_birthday'
);
echo $link = '<p><a href="' . $url . '?' . urldecode(http_build_query($params)) . '">Аутентификация через Facebook</a></p>';
if (isset($_GET['code'])) {
    $result = false;

    $params = array(
        'client_id'     => $fb_client_id,
        'redirect_uri'  => $fb_redirect_url,
        'client_secret' => $fb_client_secret,
        'code'          => $_GET['code']
    );

    $url = 'https://graph.facebook.com/oauth/access_token';
}
$tokenInfo = null;
parse_str(file_get_contents($url . '?' . http_build_query($params)), $tokenInfo);

echo $tokenInfo['access_token'].'<br>';


?>

Actually, up to this point, we just received a token. It is not clear what to do next .
<?php
if (count($tokenInfo) > 0 && isset($tokenInfo['access_token'])) {
    $userInfo = json_decode(file_get_contents('https://graph.facebook.com/me' . '?' . urldecode(http_build_query($request))), true);
        if (isset($userInfo['id'])) {
            echo $userInfo['id'];
            $result = true;
        }
    }

The only thing I could get was my id and name via the /me command

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question