php - FaceBookRequest->execute() makes my ajax call return with status 500 -
i'm trying make php script receives ajax call facebook application check if id sent user own. user id , access token in next piece of code. function validateme() puts id, letter z separator , access token together, makes ajax call
fb.getloginstatus(function(response) { if (response.status === 'connected') { monlogin.uid=response.authresponse.userid; monlogin.token=response.authresponse.accesstoken; validateme(); } }
the php script receives ajax call comes next. returns ajax call status 500 when line $response=request->execute(); not commented. when stop code before line commenting it, returns ajax call status 200. so, believe there makes line not working expected. tried changing name $faceb $session in examples, that's not it. using facebook = new facebook(array) object instead of method setdefaultapplication doesn't trick either because facebook object deprecated.
<?php session_start(); include 'vendor/autoload.php'; use facebook\facebooksession; use facebook\graphobject; use facebook\graphuser; use facebook\facebookrequest; use facebook\facebookresponse; use facebook\facebooksdkexception; use facebook\facebookrequestexception; use facebook\facebookauthorizationexception; if (isset($globals['http_raw_post_data'])){ $appid='123456'; //not true appid $psswd='123456abcdef'; //not true password facebooksession::setdefaultapplication($appid, $psswd); $infosjoueur = $globals['http_raw_post_data']; $arraydata = explode('z', $infosjoueur, 2); // arraydata[1] accesstoken javascript $session = new facebooksession($arraydata[1]); $request = new facebookrequest($session, 'get', '/me'); $response = $request->execute(); /*$graph = $response->getgraphobject(graphuser::classname()); $id = $graph->getid(); if (($arrydata[0] = $id)) { echo 'yes'; $_session['uid']=$id; } else {echo 'no';}*/ } ?>
as proposed in comments, checked logs of server , found mbstring method didn't exist because had add in composer.json file. in require, added "ext-mbstring": "*". still error 500 different log:
php fatal error: uncaught exception 'facebook\facebookauthorizationexception' message 'the access token not decrypted'
thank pointing more details on problem in server logs: mb_substr not there default php, have tell php find it.
call undefined function facebook\httpclients\mb_substr() in /app/vendor/facebook/php-sdk-v4/src/facebook/httpclients/facebookcurlhttpclient.php on line 254
the answer can found there facebook php sdk error mb_substr
(then had few bugs added while tweaking code in search of solution removing 2 in explode)
Comments
Post a Comment