Reputation: 355
I would like to know how to use the following fql query to get a single message from my facebook inbox using facebook sdk for php (or another way if it's possible )
https://graph.facebook.com//fql?q=SELECT+body+FROM+message+WHERE++mssage_id="XXXXXXXXXXXXXXXXX_XXX"&access_token=...
(returns a JSON result)
OR
https://api.facebook.com/method/fql.query?query=SELECT+body+FROM+message+WHERE+message_id="XXXXXXXXXXXXXXXXX_XXX"&access_token=...
(returns an XML result)
both methods need an access token for a read_mailbox permission. All i need is to get the result using php. Any help ?
Thanks.
Upvotes: 0
Views: 2510
Reputation: 11852
The most flexible way is to use the api
method of the PHP SDK. The Facebook documentation site has examples of this.
If you already have an access token, this code will get you the data into a php array:
<?php
$query = 'SELECT body FROM message WHERE message_id = "?????????????_??"';
$token = '????';
$result = json_decode( file_get_contents('https://graph.facebook.com/fql?q=' .
urlencode($query) . '&access_token=' . $token) );
printf('<pre>%s</pre>', print_r($result, true) );
Yes you need an access token for this. If you're trying to read the mailbox of a random user, you need an app, and you'll have to follow one of the authentication workflows to get them to log into your app and give you the read_mailbox
permission.
Upvotes: 1