Call to undefined function hash_equals() in Facebook/Helpers/FacebookRedirectLoginHelper.php -


i'm trying basic info facebook user. i'm following official docs. don't know how rid of error.

session_start(); require_once 'facebook/autoload.php'; $fb = new facebook\facebook([   'app_id' => 'xxxxx', // replace {app-id} app id   'app_secret' => 'xxxxxxxxxx',   'default_graph_version' => 'v2.2',   ]);  $helper = $fb->getredirectloginhelper();  //get access token  try {         //access token account         $access_token=$helper->getaccesstoken();  } catch (facebook\exceptions\facebookresponseexception $e) {         echo 'graph returned erorr'. $e->getmessage();         exit; }catch(facebook\exceptions\facebooksdkexception $e){         echo 'graph returned erorr'. $e->getmessage();         exit; }  echo '<h3>access token</h3>'; var_dump($accesstoken->getvalue());   $loginurl = $helper->getloginurl('https://startup-sarathjasrin.c9users.io/login/');  echo '<a href="' . htmlspecialchars($loginurl) . '">log in facebook!</a>'; 

i'm using latest facebook-php-sdk-v5.

the error says function function hash_equals() not exist. php built in hashing system available for:

(php 5 >= 5.6.0)

so if have version older 5.6.0 not have function built in. reading documentation: here

on side note able able create own hash_equals function:

if(!function_exists('hash_equals')) {     function hash_equals($str1, $str2)     {         if(strlen($str1) != strlen($str2))         {             return false;         }         else         {             $res = $str1 ^ $str2;             $ret = 0;             for($i = strlen($res) - 1; $i >= 0; $i--)             {                 $ret |= ord($res[$i]);             }             return !$ret;         }     } } 

or alternatively download compatibility package git here package newer php hashing , require code rework uses password_verify rather hash_equals


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -