简体   繁体   中英

facebook PHP api stopped working

I'm trying to write an app that will post images the user makes to a user's wall in facebook, it was working until about an hour ago now i'm getting a catch error of "An active access token must be used to query information about the current user.". hopefully someone has a quick answer :)

here is my starting PHP that gets the user and checks for the album

<?php
    include 'src/facebook.php';
    $facebook = new Facebook(array(
        'appId' => ID,
        'secret' => SECRET,
        'cookie' => true
        ));

    $me = null;
    $thisPhoto = null;
    $album_name = NAME;
    $album_message = MESSAGE;

    try {
        $me = $facebook->api('/me');
        $facebook->setFileUploadSupport(true);      
        // check if album with name exists...if not create it
        $albums = $facebook->api('/me/albums');
        foreach($albums['data'] as $album)  {
            if($album['name'] == $album_name) {
                $album_uid = $album['id'];
                }
            }
        if (!$album_uid) {
            $album_details = array(
                'message'=> $album_message,
                'name'=> $album_name
                );
            $create_album = $facebook->api('/me/albums', 'post', $album_details);
            $album_uid = $create_album['id'] . "MADE";
            }
        //echo "<!-- $album_uid -->\n";
        }
    catch (FacebookApiException $e) {
        echo "<!-- " . $e->getMessage() . " -->\n";
        }
?>

This is my main HTML (the above is called before the doctype)

<!doctype>
<html>
    <head>
        <meta charset=utf-8>
        <title>'TITLE</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <style type="text/css" media="screen">
            html, body { width:100%; background-color: #FFF;}
            body {  margin:0 auto; padding:0; width:760px}
            #flashContent { width:100%; height:100%; }
        </style>
    </head>
<body>

<?php   
    //print_r($me);
    //echo $facebook->getUser();
    //echo $facebook->getAccessToken();

    // START
    if($me) {
        // true makes print_r give human readable instead of just a screen dump
        //echo '<pre>' . print_r($VARIABLE, true) . '</pre>';
        $appName = NAME.SWF;
        $appWidth = "760";
        $appHeight = "640";
        $appID = "stache_yerself";
        $appAlt = "Square Shooters app - 'Stache Yerself";
        // ECHOS out HTML used for the APP
    }
    else {
        $loginUrl = $facebook->getLoginUrl(array('scope' => 'publish_stream,read_friendlists,user_photos'));
        echo '<a href="' . $loginUrl . '">Login</a>';
    }
?>
</body>
</html>

The else above gives a link which is there; however, does nothing it just goes to an empty page. I reset the "secret" on the app's developer page but didn't help. I have no idea why it just stopped working (did facebook change their code again?). Even the login thing from the HTML section was working before and now...nothing. I'm stumped as to why this just stopped working.

Did you hit your API limit for your dev account?

You can do 600 queries in 600 seconds.

Also, this might be helpful

https://www.facebook.com/help/210701362295828/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM