Facebook does it differently... again!
337350
protected function normalizeAccessToken($access_token) {
    if (!isset($access_token['expires_in']) && isset($access_token['expires'])) {
      $access_token['expires_in'] = $access_token['expires'];
      unset($access_token['expires']);
    }
    return parent::normalizeAccessToken($access_token);
  }
714557
public function changeInfo()
    {
        if ($this->validate()) {
            $user = $this->getUser();
            $user->full_name = $this->full_name;
            $user->company = $this->company;
            $user->tax_number = $this->tax_number;
            $user->address = $this->address;
            $user->job = $this->job;
            $user->phone = $this->phone;
            $user->birth_date = $this->birth_date;
            $user->facebook_url = $this->facebook_url;
            $user->bio = $this->bio;
            $user->save();
            return true;
        }
        
        return false;
    }
741842
function wireUsePhotoHandlers(){
    
    $usePhoto.bind('click submit', function(e){
       
      if(e.target.id === 'facebook-use-photo'){
        
        // We don't want to show the facebook option, because
        // it is the source of the image.
        $facebookDestination.hide()

        _photoToUse = localStorage.imageToPipe || $('.one-up:visible').find('img')[0].src
        
        closeOneUp()
        
        $stepFourDestinationWrapper.show()

        progressToNextStep($stepThree, function(){

          $stepFour.slideDown(333)

        })

      }

      if(e.target.id === 'twitter-use-photo'){
        
        // We don't want to show the facebook option, because
        // it is the source of the image.
        $twitterDestination.hide()
        
        _photoToUse = localStorage.imageToPipe || $('.one-up:visible').find('img')[0].src
                
        closeOneUp()

        $stepThreeDestinationWrapper.show()
        
        progressToNextStep($stepTwo, function(){

          $stepThree.slideDown(333)

        })

      }


      if(e.target.id === 'url-use-photo'){
        
        _photoToUse = $photoFromUrl.val() || localStorage.imageToPipe
        
        $stepThreeDestinationWrapper.show()
        
        progressToNextStep($stepTwo, function(){

          $stepThree.slideDown(333)

        })

      }
      
      localStorage.imageToPipe = _photoToUse

      console.log(_photoToUse)
      console.log(localStorage.imageToPipe)
      return false

    }) // end bind()
    
  }
425677
public function fb($title = null, $site = null, $url = null, $description = null, $type = null, $app = null)
    {
        if (!is_null($title)) {
            $this->property('og:title', $title);
        }

        if (!is_null($site)) {
            $this->property('og:site_name', $site);
        }

        if (!is_null($url)) {
            $this->property('og:url', $url);
        }

        if (!is_null($description)) {
            $this->property('og:description', $description);
        }

        if (!is_null($url)) {
            $this->property('og:type', $type);
        }

        if (!is_null($app)) {
            $this->property('fb:app_id', $app);
        }
    }
638473
function _createNewToken() {
    var token = uuid.v4(),
        newTokenObj = {
            _id: crypto.createHash(token, config.crypto.secret_passphrase),
            uid: this.userInfo._id.toString(),
            created: new Date().toISOString(),
            type: 'facebook'
        };

    return db.tokens.insert(newTokenObj).then(function() { return token; });
}
420935
function(req, token, refreshToken, profile, done) {
        // asynchronous
        process.nextTick(function() {
            var User = app.userModel;
            // find the user in the database based on their facebook id
            User.findOne({ 'facebook.id' : profile.id }, function(err, user) {

                // if there is an error, stop everything and return that
                // ie an error connecting to the database
                if (err)
                    return done(err);

                // if the user is found, then log them in
                if (user) {
                    if (req.session.reauthenticate) {
                      delete req.session.reauthenticate;
                      req.session.loginTime = new Date();
                    }
                    return done(null, user); // user found, return that user
                } else {
                    // if there is no user found with that facebook id, create them
                    var newUser            = new User();

                    // set all of the facebook information in our user model
                    newUser.facebook.id    = profile.id; // set the users facebook id
                    newUser.facebook.token = token; // we will save the token that facebook provides to the user
                    newUser.facebook.name  = profile.name.givenName + ' ' + profile.name.familyName; // look at the passport user profile to see how names are returned
                    newUser.facebook.email = profile.emails[0].value; // facebook can return multiple emails so we'll take the first

                    //XXX if the user with that email already exists -- associate with facebook (prompt for password?)
                    //XXX need a way for a currently logged in user to login to facebook and associate accounts

                    // save our user to the database
                    newUser.save(function(err) {
                        if (err)
                            return done(err);
                        if (req.session.reauthenticate) {
                          delete req.session.reauthenticate;
                          req.session.loginTime = new Date();
                        }
                        // if successful, return the new user
                        return done(null, newUser);
                    });
                }

            });
        });

    }
65074
def _request(self, service, **kw):
        
        fb_request = {
            'service': service,
        }
        for key in ['limit', 'offset', 'filter', 'data']:
            fb_request[key] = kw.pop(key, None)

        if kw:
            raise _exc.FastbillRequestError("Unknown arguments: %s" %
                                            ", ".join(kw.keys()))

        data = _jsonencoder.dumps(fb_request)
        _logger.debug("Sending data: %r", data)

        self._pre_request_callback(service, fb_request)
        # TODO: Retry when we hit a 404 (api not found). Probably a deploy.
        http_resp = self.session.post(self.SERVICE_URL,
                                      auth=self.auth,
                                      headers=self.headers,
                                      timeout=self.timeout,
                                      data=data)
        self._post_request_callback(service, fb_request, http_resp)

        try:
            json_resp = http_resp.json()
        except ValueError:
            _logger.debug("Got data: %r", http_resp.content)
            _abort_http(service, http_resp)
            return  # to make PyCharm happy
        else:
            _logger.debug("Got data: %r", json_resp)

        errors = json_resp['RESPONSE'].get('ERRORS')
        if errors:
            _abort_api(service, json_resp, errors)

        # If Fastbill should ever remove the REQUEST or SERVICE section
        # from their responses, just remove the checks.
        if json_resp['REQUEST']['SERVICE'] != service:
            raise _exc.FastbillError(
                "API Error: Got response from wrong service.")

        return _response.FastbillResponse(json_resp['RESPONSE'], self)
624167
function(id, params, headers, callback) {
        var url;
        url = this.client.url() + ("comments/" + (id || ''));
        return this.client.del(url, params, headers, callback);
      }
1133877
function () {
			if (F.wrap && isQuery(F.wrap)) {
				F.wrap.unbind('.fb');
			}

			D.unbind('.fb');
			W.unbind('.fb');
		}
1102609
function _linkOrCreateUser() {
    if(this.userInfo){ //If user exists link data
        return _linkIdentity(this.userInfo._id, 'facebook', this.socialUserInfo, this.creds);
    }
    else {
        return _createNewFacebookUser.call(this)
                .then(function(user){
                    this.userInfo = user;
                }.bind(this));
    }
}
739838
public function index()
    {
        //  If already logged out just send them silently on their way
        if (!isLoggedIn()) {
            redirect('/');
        }

        // --------------------------------------------------------------------------

        //  Generate an event for this log in
        create_event('did_log_out');

        // --------------------------------------------------------------------------

        //  Log social media out
        $oSocial = Factory::service('SocialSignOn', 'nails/module-auth');
        $oSocial->logout();

        // --------------------------------------------------------------------------

        //  Log user out
        $oAuthModel = Factory::model('Auth', 'nails/module-auth');
        $oAuthModel->logout();

        // --------------------------------------------------------------------------

        redirect();
    }
857101
function(service, credentials, accounts, keywords) {
  Stream.call(this, service, credentials, accounts, keywords);
  
  // Initialize FBGraph
  fbgraph.setAccessToken(credentials.access_token);
  
  // Set api endpoint URL for subscriber
  this.api_endpoint = 'https://graph.facebook.com/'+ credentials.app_id +'/subscriptions/';
  
  // Initialize subscriber object
  this.subscriber = new Subscriber(credentials, this.callback_url(), this.api_endpoint);
  
  // Initialize responder
  this.responder = new Responder();
  
  // Start listening for incoming
  process.nextTick(function() {
      this.delegateResponder();
    }.bind(this));
  
}
854665
private void requestAccountName() {
        GraphUserCallback callback = new GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user, Response response) {
                FacebookSettingsActivity activity = (FacebookSettingsActivity) getActivity();
                if (activity == null || activity.isFinishing()) {
                    return;
                }

                if (response != null && response.getError() == null && user != null) {
                    String accountName = user.getFirstName() + " " + user.getLastName();
                    if (accountName != null && accountName.length() > 0) {
                        activity.mAccountName = accountName;
                    } else {
                        activity.mHasErrorOccurred = true;
                    }
                } else {
                    activity.mHasErrorOccurred = true;
                }

                activity.tryFinish();
            }
        };

        mFacebookEndpoint.requestAccountName(callback);
    }
1211112
def send_facebook(self, token):
        
        self.send_struct('<B%iB' % len(token), 81, *map(ord, token))
        self.facebook_token = token
436202
function _logoutFacebook(successCallback, errorCallback) {
    var $this = this;

    return Facebook.logout().then(function () {

      // If successful (always), also logout from Evrythng.
      return _logoutEvrythng.call($this, successCallback, errorCallback);

    });
  }
583363
def _make_fake_message(self, user_id, page_id, payload):
        

        event = {
            'sender': {
                'id': user_id,
            },
            'recipient': {
                'id': page_id,
            },
            'postback': {
                'payload': ujson.dumps(payload),
            },
        }

        return FacebookMessage(event, self, False)
327350
public function getAvatar(){
		//Get User picture
		$params = array(/*'access_token'=>$this->access_token,*/'height'=>512,'width'=>512,'redirect'=>0,'type'=>'square');
		$userPicture = $this->get('https://graph.facebook.com/'.$this->userInfo['id'].'/picture', $params);
		if(!isset($userPicture['data'])) {
			BLog::addToLog('[Social.FB] User photo is not set!',LL_ERROR);
			return false;
			}
		$result=$userPicture['data']['url'];
		return $result;
		}