function getLongLivedToken($graphUrl)
{
    // Get cURL resource
    $curl = curl_init();
    // Set some options - we are passing in a useragent too here
    curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $graphUrl, CURLOPT_USERAGENT => 'Codular Sample cURL Request', CURLOPT_SSL_VERIFYPEER => false));
    // Send the request & save response to $resp
    $resp = curl_exec($curl);
    if (!$resp) {
        session_destroy();
        printResultsAndLogin();
        die;
    }
    curl_close($curl);
    parse_str($resp, $output);
    return $output['access_token'];
}
Beispiel #2
0
    header('Location: ' . $returnUrl);
}
?>
<!DOCTYPE html>
<html xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en-gb" lang="en-gb" >
    <head>
        <!-- load jQuery from google repository -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
        <title>social sweethearts task</title>
        <link href="style/buttonstyle.css" rel="stylesheet" type="text/css">
    </head>
    <body>

        <?php 
if (!isset($_SESSION['loggedIn'])) {
    printResultsAndLogin();
} else {
    printUserAndLogout();
}
?>

        <div id="fb-root"></div>
        <script type="text/javascript">
            window.fbAsyncInit = function () {
                FB.init({
                    appId: '<?php 
echo $appId;
?>
',
                    cookie: true, xfbml: true,
                    channelUrl: '<?php