I am in the process of putting together a Facebook tab application for a client that fetches and displays posts from a Facebook page. The application also offers the ability to add new posts to the page and comment on existing posts. This is achieved using the Facebook Graph API (through the the PHP SDK).
I have everything working but have run into a problem involving posting from my app. When a user submits a post, it is sent to the Graph API via the following request.
$facebook->api([PAGE_ID]/feed', 'POST', array(
'message' => [MESSAGE]
));
This request is successful and the post appears on the relevant Facebook page with "Via my app name" underneath it.
When I then request the list of posts on the Page via the API (request below), the aforementioned post does not appear.
$posts = $facebook->api([PAGE_ID].'/feed');
I have a strong feeling that this is due to the post being from a third party app. I have heard that Facebook "downgrades" third party posts to encourage the use of its own platform. All of the posts that were posted directly through Facebook are appearing.
However, there must be a way to retrieve these kind of posts.
Update for Fisch below
When I make the post to the API, the following post ID is returned:
112706495458566_468411663221379
However, when I make an API request for it:
$facebook->api('112706495458566_468411663221379');
I get the following response:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
However, when I make the same request but with the ID of a post already included in the /feed request.
$facebook->api('112706495458566_457890310940181');
I get the following response.
{
"id": "112706495458566_457890310940181",
"from": {
"category": "Local business",
"name": "Genting Casino Southport",
"id": "112706495458566"
},
"story": "\"Very well done to ste,...\" on their own status.",
"privacy": {
"value": ""
},
"type": "status",
"application": {
"name": "Mobile",
"id": "2915120374"
},
"created_time": "2012-11-25T22:12:21+0000",
"updated_time": "2012-11-25T22:12:21+0000",
"comments": {
"count": 0
}
}
So for some reason, Facebook isn't even letting me look up the post by its ID.
Update #2
In my search for an answer to this, I have come across a study which strengthens my earlier suspicions about the "weight" assigned to third party app posts.
From the EdgeRank Checker report: "When an object is created in Facebook, it is assigned a weight. We believe that Facebook strategically reduced the weight of objects created through the API. The reason behind this strategy would be to encourage more content creation within the Facebook Platform. This ultimately increases the value of their platform while increasing ad impressions."
http://adage.com/article/digitalnext/posting-facebook-truth-party-applications/229694
This could explain why the posts are not passed through in the /feed or /posts API response.
However, this does not explain why the API will not even return the post by it's ID (see update above).
All I can think of is that Facebook does not class third party app posts as real "Posts" and thus doesn't push them through on the appropriate API response. However, I can find no evidence of this in the Facebook documentation.
Update #3
Based on the comments below, I am now attempting to do the same but using a Facebook account that is not the owner of the app or in fact has any admin relation to any page on Facebook (my own personal Facebook account).
I have authorised the app using the oAuth dialog and have accepted the following permisions:
- user_birthday
- publish_stream
With my shiny new access token, I make the following API request:
$post = $facebook->api('112706495458566/feed', 'POST', array(
'message' => 'this is a test'
));
To which I receive the following response:
array(1) {
["id"] => string(31) "112706495458566_470663409662871"
}
I then check the actual Facebook page, the post that I just sent has appeared from my Facebook user account as expected.
I then make the following request to fetch all posts on the page:
$posts = $facebook->api('112706495458566/feed');
To which I receive a long array of all the posts on the page (which I wont post here). However, the post that I just sent (and received an ID back for) does not appear.
I then make a direct request for that post using the ID that was returned by the POST request.
$post = $facebook->api('112706495458566_470663409662871');
Which throws the following exception (as per the previous attempt).
GraphMethodException: Unsupported get request.
To reiterate, this attempt was using an account that is completely unrelated to the app or any of the pages that we are trying to fetch data for. The account has also never had any contact with the app (i.e. this was the first time that the permissions have been accepted and an oAuth key generated).