php - FacebookSDK search by username/pagename -
i'm trying access public information user based on username/pagename.
i'm doing this:
$uname = 'csga5000'; $session = new facebook\facebook([ 'app_id' => self::$facebook_app_id, 'app_secret' => self::$facebook_app_secret, 'default_graph_version' => 'v2.2' ]); try { // returns `facebook\facebookresponse` object $response = $session->get('/search?q='+$uname+'&type=user'); } catch(facebook\exceptions\facebookresponseexception $e) { print_r($e); echo 'graph returned error: ' . $e->getmessage(); exit; } catch(facebook\exceptions\facebooksdkexception $e) { echo 'facebook sdk returned error: ' . $e->getmessage(); exit; }
but exception thrown, here output:
graph returned error: (#803) of aliases requested not exist: v2.20
alternatively(got looking @ source code)
$response = $session->sendrequest('get','/search',['q'=>$uname,'type'=>'user']);
returns "graph returned error: access token required request resource." stole reference somewhere using app id , secret token in format:
$response = $session->sendrequest('get','/search',['q'=>$uname,'type'=>'user'], self::$facebook_app_id.'|'.self::$facebook_app_secret);
this throws: "graph returned error: user access token required request resource."
i don't understand why user access token required :/
anyone know how search user based on username in php? i've seen other examples outdated, pretty same claim worked.
edit: information want acquire follower count.
first of all, can´t search users username anymore. earlier possible using simple api call: graph.facebook.com/username
this not work anymore, , search api allows search name (first/last). not supposed use username anymore.
that being said, need authorize , use user token, error message tells you. that´s how is, , can read in docs too:
- searches across page , place objects requires app access token.
- all other endpoints require user access token.
source: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.4#search
more information tokens:
Comments
Post a Comment