Can my Facebook App programatically subscribe to real-time-updates on multiple Page/User profiles? - facebook

I would like to get notified programatically (using the callback URL) that any one of 100 Facebook Pages (or a User, but less important) has posted a new post to their Timeline/Feed or edited some of the Page details such as opening times for example.
My understanding from reading this documentation https://developers.facebook.com/docs/graph-api/real-time-updates/v2.3 is that I can "Subscribe" to changes programatically for multiple Objects (i.e. 50 Pages and 100 Users) using my App providing i have Permissions to do so from the User (I only want publicly available Page data).
I don't see the value in this "Subscribe" functionality if it does not do what the above requirements describes
Update: I have edited the question slightly as the initial question was found to be a bug in the Facebook user documentation as discovered by the comment below.

https://developers.facebook.com/docs/apps/changelog#v2_2_new_features
There is a new endpoint called subscribed_apps - you can connect an App to a Page without adding it as Tab now, so it does not show up for the users. The rest is the same, you still need /subscriptions to add a subscription (with callback and object) - but there is a bug in the docs, it´s not removed in v2.3: https://developers.facebook.com/bugs/799294656844725/
Btw, of course you can´t subscribe to a Page you don´t own. You have to be Moderator at least.

Related

How to set up Facebook webhook to monitor a particular page

I've been searching the net on how to setup the Facebook webhooks to check a particular Facebook page (I'm a content editor of) for certain updates.
I read the docs many times about setting up the callback URL whenever a particular "event" happens on that Facebook page, but I never read a straight answer on how to tell which page I want to monitor in.
I was pointed to the {app-id}/subscriptions endpoint, but it doesn't seem to be the one I need.
Could someone provide an idea on how this works?
You need to make a request to /{page_id}/subscribed_apps to create a subscription for updates from a page.
This call needs a page access token, so you need to request manage_pages permission first from an admin of the page. (Not sure if “content editor” role is sufficient for that.)

Legal ways to get all recent posts of multiple Facebook pages as soon as possible?

I want to get all the newest posts from 10 (or let's say 1xxxxx) Facebook pages (which I do not own) as soon as they there published without manual refreshing all 10 pages every second. What legal tools should I use?
Use the Facebook Graph API. It allows you to get your application notified via callback HTTP posts whenever certain updates occur. You'll find the API documentation for this feature here:
https://developers.facebook.com/docs/graph-api/real-time-updates/v2.2
Based on your usage, you may have to pay for that service.

Maintaining continuity of a Facebook post from website to Facebook

I am building a social application, users post data to the website, which is saved in our database.
This creates a record on the site, which is searchable and creates the basic content and function of the site (the purpose is not relevant at this point)
When a record is saved to our database, I want to "spread the word" and send this data out to social networks. Currently, I'm looking at Facebook in isolation.
So, I know how to create a post through the Graph API and post this content to the users Timeline, or indeed to a business page associated with the APP/Website.. but I am not sure how, or if indeed one should, maintain continuity.
What I mean... if a user creates a record on my website, and then the website/App creates a post on my business page, and also asks the user to post it in their Timeline, how do I stop this being two separate posts, and instead one post which has been shared?
I want to achieve:
User posts on website
>
Website posts to Page
>
Post on Page is "Shared" to users Timeline
As opposed to:
User posts on website
>
Website posts to Page
>
Website posts an additional post to users Timeline
The reason I want to do this, is that on the website, I want to be able to show shares, likes and comments from Facebook by tracking the ID of the initial post created when first entered onto my website.
Or am I trying to reinvent the wheel and should just use Facebook's comment plugin?
When you create the post on facebook on the Page, store the returned post ID in your data model.
From what I can tell, there is no way to access the normal user share directly through the API. If you insist on doing it programmatically without popping up any dialog for your user, you can make a post to the user's page which has (the start of) the Page post and a linkback to the Page post as an attachment. This is probably to prevent abuse.
However, if you don't mind relying on an undocumented and deprecated endpoint, you can use the old sharer.php endpoint, so long as you have a fully qualified link to the post you want to share (you can retrieve the url through the api). This will also require your user to enter anything appropriate in their share and then click "share."
The endpoint is
http://www.facebook.com/sharer.php
Call it with the u parameter filled in with the url, so
http://www.facebook.com/sharer.php?u=[URL encoded URL of the post you wanted to call]
You can try this with any facebook post (go to a post, copy the url, past in as the parameter), it's still working (I just tried it) but there are no guarantees. See the top answer to Facebook API: "Share" a post already posted on a page's wall?.
You can still access likes, comments, etc for that post id through the Graph API (and you can provide your users a direct link to the post). Cache/update them as recommended and display them on your own page. You are basically mirroring back onto your own site what is happening on facebook in regards to the post you made.
I would go this route especially if you are at all planning on branching into other services. That way you can do an aggregated display of statistics/likes/etc from the multiple services you are having your platform repost to. This is also good for (at least an impression of) data integrity for your users: they know that your service represents everything they have done in case anything happens to their facebook/etc accounts.
This could especially be noteworthy if they are worried about facebook/etc deleting any of their posts, or for recovering from any issues where a post/comment/etc is not properly stored by facebook/etc (for example, comments have a maximum length which, at least via the main FB UI, silently drops anything above the maximum length in a non recoverable way for the user).

Remove Facebook page likes automatically with Facebook API

As detailed in the my post on IT Security Stack Exchange, I am the administrator for a page with a many recent unknown (an undesired) likes.
It was suggested to me to learn the Facebook API and write an algorithm to remove likes automatically, based on thresholds (ex.: remove a like if the user has a suspicious amount recent likes).
I'm aware of the many other posts discussing issues with retrieving the like count for a Facebook page, but was unable to find any posts discussing removing likes as the page admin.
Is this possible to achieve? If so, how would this be done?
Try looking into using the block method.
PAGE_ID/blocked?uid=USER_ID_YOU_WANT_TO_BLOCK
This should do the same as removing the like. I am not sure whether unblocking the user resets the like or not (works on Twitter) so you can look into that as well with a HTTP DELETE on the same call.
As far as I know there is no way to explicitly remove a like from a page.
For more information see http://developers.facebook.com/docs/reference/api/page/#blocked

Facebook graph API returns empty data for a page

I have an application that is retrieving data from Facebook. Users authorize the application to read and write to their pages, and we read their data and post to it from our application. All interaction occurs via the PHP interface that Facebook supplies.
For the last few months our application has been performing this task flawlessly. However in recent days we have started noticing an issue with certain pages.
We go out and retrieve data for a specific page, and we no longer get any data. Instead Facebook returns us an empty result. This obviously causes problems in our application which needs to read this data.
We can still write data just fine.
I am at a point where I'm not sure what this could be. Any common scenarios or recent Graph API issues that could cause this?
This sounds odd. The only thing that comes to mind is that the page owner has put a restriction on the audience for their page, which would then require you to pass in an access token to access data about the page. An example would be a beer company that wants to limit access to their FB page to users that are older than 21. Since there is a restriction on who can access the page content, we enforce that restriction on the FB platform. In this case you would need to pass in the access_token of a user who is 21 or older to access the page details via the graph api.
Adding to Jeff's answer, I found that any kind of restriction whatsoever will return a blank data object. I was banging my head on every single setting on my company's page and found that we had it set to only show in certain countries (Manage Settings > Country Restrictions). Removing all of them from the list started to return all the data we needed.