Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6951953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:17:08+00:00 2026-05-27T14:17:08+00:00

Facebook integration has been working perfectly on my site for some time, then overnight

  • 0

Facebook integration has been working perfectly on my site for some time, then overnight something happened at facebook because it’s now failing.

Can someone have a look at the code I use all over my site and advise what I should do to get this working again as soon as possible, without having to remodel the whole implementation?

<?php
// http://developers.facebook.com/docs/reference/fql/user

class Facebook_class
{

var $cookie;

function Facebook_class() {
    $this->cookie = $this->get_facebook_cookie(FACEBOOK_APP_ID, FACEBOOK_SECRET);
}

function getUserid() {
    $cookie = $this->getCookie();
    $fb_userid = $cookie['uid'];
    return $fb_userid;
}

function getProfilePicture() {
    $url = 'https://graph.facebook.com/'.$this->getUserid().'/picture?type=large';
    //$url = 'api.facebook.com/method/fql.query?query=SELECT pic_big FROM user WHERE uid = '.$this->getUserid();
    $url = $this->get_redirect_url($url);
    return $url;
}

function getUserData() {
    if($this->getCookie()) {
        $url = 'https://graph.facebook.com/me?access_token='.$this->getAccessToken();
        $userData = json_decode(file_get_contents($url));
        return $userData;
    }
}

function getCookie() {
    return $this->cookie;
}

function getAccessToken() {
    return $this->cookie['access_token'];
}

function loadJsSDK($path_to_library='') {
    echo '<script type="text/javascript"> 
    //<![CDATA[ ';

    ?>
    function logoutFacebookUser(){FB.logout(function(response){window.location.reload();});}
    function fbActionConnect(){FB.login(function(response){if (response.session){window.location = "http://www.mysite.com/signin/fbconnect";if(response.perms){}else{}}else{}}, {perms:'publish_stream,email'});}
    function fbAppActionConnect(){FB.login(function(response){if (response.session){window.location = "http://www.mysite.com/signin/fbappconnect";if(response.perms){}else{}}else{}}, {perms:'publish_stream,email'});}
    function fbLinkActionConnect(){FB.login(function(response){if (response.session){window.location = "http://www.mysite.com/index.php?name=signin&file=MyServices&op=linkacc";if(response.perms){}else {}}else{}},{perms:'publish_stream,email'});}
    function fbActionCartConnect(id, sport) {FB.login(function(response){if(response.session){window.location = "//index.php?name=signin&file=cart&id=" + id + "&sport=" + sport + "&op=fbsignup";if (response.perms){}else{}}else{}},{perms:'publish_stream,email'});}
    window.fbAsyncInit = function() {FB.init({appId: xxxxxxxxxxxxxxxxx, channelUrl:'http://www.mysite.com/channel.html', status: true, cookie: true, xfbml: true});};(function() {var e = document.createElement('script'); e.async = true;e.src = document.location.protocol +'//connect.facebook.net/en_US/all.js';document.getElementById('fb-root').appendChild(e);}());//]]></script>
    <?php
}

function get_facebook_cookie($app_id, $application_secret) {
  $args = array();
  parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
  ksort($args);
  $payload = '';
  foreach ($args as $key => $value) {
    if ($key != 'sig') {
      $payload .= $key . '=' . $value;
    }
  }
  if (md5($payload . $application_secret) != $args['sig']) {
    return null;
  }
  return $args;
}

function get_redirect_url($url) {
    $redirect_url = null; 

    $url_parts = @parse_url($url);
    if (!$url_parts) return false;
    if (!isset($url_parts['host'])) return false; //can't process relative URLs
    if (!isset($url_parts['path'])) $url_parts['path'] = '/';

    $sock = fsockopen($url_parts['host'], (isset($url_parts['port']) ? (int)$url_parts['port'] : 80), $errno, $errstr, 30);
    if (!$sock) return false;

    $request = "HEAD " . $url_parts['path'] . (isset($url_parts['query']) ? '?'.$url_parts['query'] : '') . " HTTP/1.1\r\n"; 
    $request .= 'Host: ' . $url_parts['host'] . "\r\n"; 
    $request .= "Connection: Close\r\n\r\n"; 
    fwrite($sock, $request);
    $response = '';
    while(!feof($sock)) $response .= fread($sock, 8192);
    fclose($sock);

    if (preg_match('/^Location: (.+?)$/m', $response, $matches)){
        if ( substr($matches[1], 0, 1) == "/" )
            return $url_parts['scheme'] . "://" . $url_parts['host'] . trim($matches[1]);
        else
            return trim($matches[1]);

    } else {
        return false;
    }
}

function getFacebookFriends($criteria='') {
    $name = $criteria['name'];

    if($name=='') $name = 'me';

    $url = 'https://graph.facebook.com/'.$name.'/friends?access_token='.$this->getAccessToken();
    $content = @file_get_contents($url,0,null,null);
    $content = json_decode($content,true);

    $users = $this->formatFacebookUsers($content);

    return $users;
}

function formatFacebookUsers($content) {
    for($i=0; $i<count($content['data']); $i++) {
        $id = $content['data'][$i]['id'];
        $name = $content['data'][$i]['name'];

        $picture = 'https://graph.facebook.com/'.$id.'/picture?type=square'; //square, small, large
        $url = 'http://www.facebook.com/profile.php?id='.$id;

        $users[$i]['id'] = $id;
        $users[$i]['name'] = $name;
        $users[$i]['picture'] = $picture;
        $users[$i]['url'] = $url;
    }
    return $users;
}

function getFacebookAccounts() {
    $url = 'https://graph.facebook.com/me/accounts?access_token='.$this->getAccessToken();
    $content = @file_get_contents($url,0,null,null);
    $content = json_decode($content,true);
    return $content;
}

function displayUsersIcons($criteria) {
    $users = $criteria['users'];
    $nb_display = $criteria['nb_display'];
    $width = $criteria['width'];

    if($width=='') $width="30";

    if($nb_display>count($users) || $nb_display=='') $nb_display=count($users); //display value never bigger than nb users

    $display = '';
    for($i=0;$i<$nb_display;$i++) {
        $name = $users[$i]['name'];
        $picture = $users[$i]['picture'];
        $url = $users[$i]['url'];

        $display .= '<a href="'.$url.'" target="_blank" title="'.$name.'">';
        $display .= '<img src="'.$picture.'" width="'.$width.'" style="padding:2px;">';
        $display .= '</a>';
    }
    return $display;
}

function getFacebookFeeds() {

    $url = 'https://graph.facebook.com/me/posts?access_token='.$this->getAccessToken();

    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    $data = curl_exec($ch);
    curl_close($ch);

    $data = json_decode($data,true);
    $dataList = $this->formatFacebookPosts($data);

    return $dataList;
}

function formatFacebookPosts($data) {
    $i=0;
    foreach($data['data'] as $value) {
        $id = $value['id'];
        $from_id = $value['from']['id'];
        $from_name = $value['from']['name'];

        $type = $value['type']; //video, link, status, picture, swf
        $message = $value['message'];
        $picture = $value['picture'];
        $link = $value['link'];
        $source = $value['source']; //for videos
        $name = $value['name']; //for videos or links
        $caption = $value['caption']; //for videos (domain name url) or links
        $description = $value['description']; //for videos
        $icon = $value['icon'];
        $created = $value['created_time'];
        $likes_nb = $value['likes'];

        $comments = $value['comments']['data']; //(message, created_time)
        $comments_nb = $value['comments']['count'];
        $action_comment = $value['actions'][0]['link'];

        $picture_url = 'https://graph.facebook.com/'.$from_id.'/picture';
        $profile_url = 'http://www.facebook.com/profile.php?id='.$from_id;

        $attribution = $value['attribution'];

        if($type=='status') {
            $dataList[$i]['id'] = $id;
            $dataList[$i]['from_id'] = $from_id;
            $dataList[$i]['from_name'] = $from_name;
            $dataList[$i]['type'] = $type;
            $dataList[$i]['message'] = $message;
            $dataList[$i]['picture'] = $picture;
            $dataList[$i]['link'] = $link;
            $dataList[$i]['source'] = $source;
            $dataList[$i]['name'] = $name;
            $dataList[$i]['caption'] = $caption;
            $dataList[$i]['description'] = $description;
            $dataList[$i]['icon'] = $icon;
            $dataList[$i]['created'] = $created;
            $dataList[$i]['attribution'] = $attribution;
            $dataList[$i]['likes_nb'] = $likes_nb;
            $dataList[$i]['comments'] = $comments;
            $dataList[$i]['comments_nb'] = $comments_nb;
            $dataList[$i]['action_comment'] = $action_comment;
            $dataList[$i]['picture_url'] = $picture_url;
            $dataList[$i]['profile_url'] = $profile_url;
            $i++;   
        }
    }
    return $dataList;
}

function updateFacebookStatus($status) {
    $postParms = "access_token=".$this->getAccessToken()."&message=".$status;
    $ch = curl_init('https://graph.facebook.com/me/feed');

    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postParms);
    $results = curl_exec($ch);
    curl_close($ch);
}

function postmsg() {
    $FILE_PATH = $_SERVER["DOCUMENT_ROOT"]."images/default/webedition1.jpg";
    $token=$this->getAccessToken();

    if (file_exists($FILE_PATH)) { 

       $args = array('message' => 'From the coaches locker');
    $args['image'] = '@' . realpath($FILE_PATH);


    $arr_attachment = array('image' => '@'.realpath($FILE_PATH),
                            'message' => 'Test caption'
                        );
    $_curl = curl_init();
    curl_setopt($_curl, CURLOPT_URL, "https://graph.facebook.com/me/photos?access_token=".$token);
    curl_setopt($_curl, CURLOPT_HEADER, false);
    curl_setopt($_curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($_curl, CURLOPT_POST, true);
    curl_setopt($_curl, CURLOPT_POSTFIELDS, $arr_attachment);
    curl_setopt($_curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($_curl, CURLOPT_SSL_VERIFYPEER, 0);

    $_photo = curl_exec($_curl);
    echo($_photo);

    } else {
    echo "cannot find file:".$FILE_PATH;
    }
}


}

?>

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:17:09+00:00Added an answer on May 27, 2026 at 2:17 pm

    Facebook introduced some breaking changes for OAuth2 authentication to the JavaScript SDK yesterday: http://developers.facebook.com/blog/post/614/

    More details: http://developers.facebook.com/blog/post/525/

    Basically some changes I’ve seen were:

    1. FB.getSession() now changed to FB.getAuthResponse()
    2. FB.init() now has the ‘oath’ value as always ‘true’.
    3. ‘perms’ is now changed to ‘scope’ in the login button html
    4. Possibly FB.Event.subscribe(‘auth.sessionChange’..) is now FB.Event.subscribe(‘auth.authResponseChange’..)

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an iphone application which has some facebook integration in it.I added
I am using FbGraph API for facebook integration. Everything is working fine, but the
I am integration Facebook connect in my website using php SDK.. Everything is working
OK, I need some help understanding the process behind Facebook's website integration process and
I'm integrating the Facebook Like Button into a site. The likeing functionality is working
I am working on a rails application. I have implemented facebook integration in my
I have been following through the below link for Facebook integration and could able
I have began developing a website which has facebook integration and it seems to
I have a website with Facebook integration. The homepage has a few Like buttons,
If you watch the video below, Kodak has implemented Facebook integration into their kiosks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.