Facebook php sdk: getUser = 0


February 25, 2014 at 09:15
Facebook

I already wrote about getUser returning 0 before, but lately not even my workaround seems to help. No matter what I tried, after giving permissions getUser always returns 0 on the first try. After a long google search that brought no results, I was fed up with this facebook crap and instead, I searched in the Facebook PHP SDK for answers. What I found was a function called getCode in base_facebook.php that seemed to be the source of the problem. And since time is precious, I just edited it:
  protected function getCode() {
    if (!isset($_REQUEST['code']) || !isset($_REQUEST['state'])) {
      return false;
    }
    //return $_REQUEST['code'];
    if ($this->state === $_REQUEST['state']) {
        // CSRF state has done its job, so clear it
        $this->state = null;
        $this->clearPersistentData('state');
        return $_REQUEST['code'];
    }else{
      return $_REQUEST['code'];
    }
    self::errorLog('CSRF state token does not match one provided.');

    return false;
  }
This may be bad style, since I don't even know what this is supposed to do, but you know what? It works and I've had it with Facebook and it's stupid behaviour.

Tags: base_facebook.php facebook php sdk getuser


Hinterlasse einen Kommentar:
Shikhar Bansal
05.10.2014
This did not work for me . The problem continues...

Theepan
27.04.2014
After 24hrs of different solutions this worked for me. Thanks a lot. I hate Facebook

Search