Thanks for the help. I will finally figure out how to do this.
Firstly, I need to get an access token, not a user session, but one for the administrator.
So here is the code:
$url = 'https://graph.facebook.com/oauth/access_token'; $ch = curl_init(); $params = array( 'grant_type'=>'client_credentials', 'client_id'=>$appId, 'client_secret'=>$secret, ); $opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&'); // set URL and other appropriate options curl_setopt_array($ch, $opts); curl_setopt($ch, CURLOPT_URL, "$url"); curl_setopt($ch, CURLOPT_HEADER, 0); // grab URL and pass it to the browser $adminAccessToken = curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch);
And then I can use the facebook API to get any user that accepts the application and extended permission:
$fql = "select name, hometown_location, sex, pic_square, email from user where uid=1000000001"; $param = array( 'method' => 'fql.query', 'query' => $fql, 'access_token' =>$adminAccessToken , 'callback' => '' ); $fqlResult2 = $facebook->api($param);
with an access token, I can also send messages to the user's wall. :)
murvinlai
source share