Using facebook SDK for php for an FQL query?
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 )
(returns a JSON result)
(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 ?
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.