i am having a heck of a time getting facebook real time updates to work for a page. true, this question may have been asked - more than once - but i have not seen a definite routine given as an answer. mostly just disjointed suggestions. as a disclaimer - allow me to add i have read the documentation all over many times. you will see this when i post my routine. i am getting no updates after all of this.
create a page. named Testerthree, category : brands & products : app page, website : _http://< mydomain >.com, page id :
developers.facebook.com
i create an application : Testerthree
a. settings : Testerthree namespace : tester_three
b. create a platform : website : Site URL : Mobile Site URL : _http://< mydomain >.com
c. add a platform : page tab :
Page Tab Name : Testerthree Secure Page Tab URL : _http://< mydomain >.com
d. app domains : _http://< mydomain >.com
e. app details : i fill out all the info for the top box. category : apps for pages
this is where things get kinda weird. there's a button there under "App Page" to create a new page for the app....sometimes this works automatically and sometimes it doesnt. basically i do know now how to connect a page to this field. however erratic the process is. basically, listed here for "App Page" - is a page i created with the same name : Testerthree
app id : < app id > app secret : < app secret >
so at this point what i would have is a page : Testerthree
and an app : Testerthree
I have the page listed in the App Details page as the role of App Page
then i begin trying to get the requests to query and configure facebook. this process appears to work, and create a subscription, but nothing is ever sent from my page to my server through the app. if i subscribe to USER fields through the app, they update. if i subscribe to the PAGE fields, i get no update. either way, here goes :
get access token :
_https://graph.facebook.com/oauth/access_token?client_id=< app id >&client_secret=< app secret >&grant_type=client_credentials
not sure if this is needed, but it was a piece of the puzzle i never let go :
_https://graph.facebook.com/oauth/authorize?client_id=< app id >&redirect_uri=_http://< mydomain >.com/fb/return.php&scope=manage_pages,offline_access,read_stream
creating the subscription :
_https://graph.facebook.com/< app id >/subscriptions?access_token=&object=page&fields=feed,description,general_info&verify_token=&method=post&callback_url=_http://< mydomain >.com/fb/facebook-subscribe.php
now i DO have the entry point on my server at _http://< mydomain >.com/fb/facebook-subscribe.php
the code in it looks liike the code specified here (facebook-subscribe.php) :
http://mwc.byteshaman.us/fb/fbsubscribe-code.php
which should take any post data and output to a file. honestly prior to all this i put a small random fopen, to create an output txt file, if this .php is ever viewed or pinged. when i create the subscription, the txt is made. when i test my subscription, no txt is made.
either way
i check the subscription with this :
_https://graph.facebook.com/< app id >/subscriptions?access_token=&method=get
and it DOES show a subscription like this :
{
"data": [
{
"object": "page",
"callback_url": "_http://mydomain.com/fb/facebook-subscribe.php",
"fields": [
"description",
"feed",
"general_info"
],
"active": true
}
]
then i connect the page with the app with this :
_https://www.facebook.com/dialog/pagetab?app_id=< app id >&redirect_uri=http://< mydomain >.com/fb/return.php
this is an insane amount of steps to subscribe to a feed. cheers to facebook. someone please aim me in the direction to the part in their documentation where they give one complete cohesive example of any of this....
well, it appears as if i have a subscription setup after all this. the page is listed in my app details. the subscription is showing subscribed.
yet when i update my page feed, or change some of the description data (which is supposed to be subscribed to) I get nothing.
anyone please help?i've done all the homework possible, and this post is my last attempt after 3 days, before gaining the absolute belief that this routine is impossible and there's actually no such thing as realtime updates for facebook pages, like the Easter bunny, or Santa claus.
is it possible? does anyone know the routine? can anyone identify where i messed up?
thank you.
i have the answer : cron jobs. the facebook real time api is erratic when it comes to pages. the solution was to never use the facebook realtime update api and just use a cron job instead. thanks for playing. there was no winner or loser.
Related
I'm integrating google assistant with my application. The problem is when I send a report state request to assistant while inside a device screen in google home application, I get a 200 OK response with the requestId I'm sending, but the device screen doesn't update with the device state. (It gets updated after I go back and go to device screen again but that is done through query intent)
Sample Request Body
{
"payload" : {
"devices" : {
"states" : {
"12364" : {
"on" : true
}
}
}
},
"requestId" : "A7TNpoXlnG0OQWzpTvJAa4sjolAAt46q",
"agentUserId" : "14556"
}
Sample Response Body
{ "requestId" : "A7TNpoXlnG0OQWzpTvJAa4sjolAAt46q" }
This is their documentation regarding the report state.
I even deployed the report state dashboard locally to monitor the state changes but it doesn't update as well.
Can anyone point me in right direction? Thanks!
The behavior of different Assistant surfaces with respect to Home Graph changes can vary, so it's best not to rely on looking for real-time UI changes in the Google Home app.
The Report State Dashboard noted in the documentation that you linked is a good way to validate the state you publish to Home Graph graphically. We also recently published an AoG ProTips episode on this topic that shows you how to do the same from the command line.
Neither of these methods will update automatically in real-time either, but you can refresh them after publishing a state change to verify the right data is in Home Graph.
So I am building a restaurant app and one of the features I want is to allow a user of the app to see photos from a particular restaurant's Instagram account.
And I want a user to be able to see this without having to login to their Instagram account, so they shouldn't even need an Instagram account for this to work.
So I have read this answer How can I get a user's media from Instagram without authenticating as a user?
And I tried what it said and used the client_id(which I recieved when I registered my app using my personal Instagram account), but I still get an error back saying :
{
meta: {
error_type: "OAuthAccessTokenException",
code: 400,
error_message: "The access_token provided is invalid."
}
}
The endpoint I am trying to hit is :
https://api.instagram.com/v1/users/search?q=[USERNAME]&client_id=[CLIENT ID]
So do I absolutely need an access token for this to work(and thus have to enforce a user to log in) ?
If I do, then is there way to generate an access token somehow without forcing the user log in?
I believe there is a way around this, as the popular dating app Tinder has this desired functionality I am looking for, as it allows you to see photos from people's Instagram account without having to log in! (I have just verified this 5 minutes ago!)
Any help on this would be much appreciated.
Thanks.
Edit April 2018: After facebook privacy case this endpoint is immediately put out of service. It seems we need to parse the JSON embedded in <script> tag directly within the profile page:
<script type="text/javascript">window._sharedData = {"activity_counts":...
Any better ideas are welcome.
You can use the most recent link
GET https://www.instagram.com/{username}/?__a=1
to get latest 20 posts in JSON format. Hope you put this to good use.
edit: other ways aren't valid anymore:
https://www.instagram.com/{username}/media/
Instagram used to allow most API requests with just client_id and without access_token, the apps registered back in the day still work with way, thats how some apps are able to show instagram photos without user login.
Instagram has changes the API specification, so new apps will have to get access_token, older apps will have to change before June 2016.
One way you can work around this is by using access_token generated by your account to access photos. Login locally and get access_token, use this for all API calls, it should not change, unless u change password,if it expires, regenerate and update in your server.
Since the endpoints don't exist anymore I switched to a PHP library -
https://github.com/pgrimaud/instagram-user-feed
Installed this lib with composer:
composer require pgrimaud/instagram-user-feed "^4.0"
To get a feed object -
$cache = new Instagram\Storage\CacheManager();
$api = new Instagram\Api($cache);
$api->setUserName('myvetbox');
$feed = $api->getFeed();
Example of how to use that object -
foreach ($feed->medias as $key => $value) {
echo '<li><img src="'.$value->thumbnailSrc.'"></li>';
}
I'm trying to integrate realtime updates for user pages. I have a callback running on a given HOST url. Having this the subscription creation is:
G = facebook.GraphAPI()
app_token = config['FACEBOOK_APP_ID'] + '|' + config['FACEBOOK_SECRET']
path = config['FACEBOOK_APP_ID'] + '/subscriptions'
post_args = {'access_token' : app_token, 'callback_url' : HOST, 'fields' : 'feed', 'object' : 'page', 'verify_token' : 'token'}
G.request(path, post_args=post_args)
This seems to work just fine and a subscription is created. After this, for a given user I get oauth credentials with perms = ["publish_stream", "offline_access", "manage_pages", "publish_actions", "read_stream"]
Using this access token, I do a subscribe by adding the app to the page tabs:
G = facebook.GraphAPI(access_token)
path = "/%s/tabs" % page['id']
G.request(path, post_args={'app_id' : config['FACEBOOK_APP_ID']}
Now things work.... sort of. First thing is I'm not sure exactly how facebook testing should work in practice. Basically I created a bunch of test users using the app settings on developers page. Then using one of these users, I create two separate pages Page1, Page2 and I registered the app as a tab on these pages. Posts issued from the test users, or from the real user I created the app with are picked up. But I try to find one of the pages from some other real user (so not a test one and not the one I created the app with) and I cant. Even if I copy paste the entire URL, I just get a redirect to the first page. Are those pages only visible inside my own test app/users context ? Should I create a page from my real account and test with that? I'm just curious on how would I go around testing this in a real setup. Would I get ALL comments / posts on that page regardless of the user who does the posting or just posts from the Page / Admins of the page ?
Another separate problem I'm having is creating a comment from some user. So I'm using the exact same access token I've got above, and having a post from someone come it, I want to issue a reply in the form of a comment on that post. I have the facebook post id, so I just:
graph = facebook.GraphAPI(access_token)
graph.put_comment(facebook_post_id, message)
Say I issue this command using the access token I got from TestUser1 on a post that came on his own page Page1 . I would expect that the comment be posted on behalf of TestUser1 but instead it gets posted on behalf of Page1 . Is this expected as a side effect of the token I'm using? I've read here https://developers.facebook.com/docs/facebook-login/access-tokens/ that there are user access tokens and page access tokens; but I've tried the exact same thing with a token without the 'manage_pages' perms and still get the same thing.
Cheers, Bogdan
Before I ask my question here are a few details of my setup and the problem I am facing.
This is my first post on StackOverflow :).
Platform :
Unity3d engine + Prime31 plugin for Facebook
Context :
I am trying to integrate Facebook into our Mobile iOS app, developed using Unity3d (still in development), and I am trying to post to the user's friend's wall using a plugin called Prime31.
Problem :
I keep getting a 403 forbidden error when I post to the friends wall
Code :
I am using the following piece of code
var token = FacebookBinding.getAccessToken();
Debug.Log( "access token: " + token );
var param = new Dictionary<string,object>
{
{"message", "Test message for dragons "},
{"access_token" , token},
{"name", "School of Dragons"},
{"caption", "Join the world of Dragons"},
};
Facebook.instance.post(id+"/feed",param, OnPostComplete);
Where id is retrieved from another piece of code.
Additional Info :
With the same setup, publishing on my own wall works. (me/feed instead of id/feed)
The friend I am trying to post to and myself both are listed as developers in the account for the app.
I have the the info.plist additions according to the steps provided by Prime31.
I have done extensive googling on this problem and most of the replies indicate a high number of posts being made from the server / app as a possible reason.
Questions :
Is filling in the Native IOS App setting in the developer console a must for publishing ?
Is the number of posts made by a developer application in Facebook restricted ? Because I can post to the same friends wall with the same content outside of the app. This seems to be the least likely scenario.
Why could this problem be happening ?
Any help would be greatly appreciated as we have a deadline approaching in three days and this feature should be done and ready in a couple of days.
Thanks
Anur
When I use me/photo to share a picture I have meet 403 error.My case is because of my Facebook app not approve the publish_actions permission,and I use a normal user for test,just test user can use not approved permissions.You can use app manage page's menu "Status & Review" -> "Submission" to request permission.
Well, I'm using unity3D I had the same FBResult::Error (res.Error.Text) text (403 forbidden)
You need to see what the res.ToString() says.
For example mine is
""message":"(#200) Requires extended permission: publish_actions","type":"OAuthException","code":200,"fbtrace_id":"C3X4jSCm7or"
This is the first time I'm trying to develop a facebook app so sorry in advance if my question is too naive.
What I need to do is making a chat-like facebook application where:
the user can write something on the wall
the app should be able to detect this event and send an HTTP request to an external web service of my own which will provide a response (text)
publish that text as a comment
the user should be able to continue the dialog by entering another comment(s) (in which case we go back to step #2)
Basically, this would be very similar to:
https://www.facebook.com/SkyscannerFlightSearch
I think one (ugly) way to do this would be making a script which searches for new wall entries/comments and posts replies in an infinite loop by using the Graph API but it's obviously sub-optimal and expensive.
Is there any way to have facebook call a certain url every time a wall post/comment is entered?
Or maybe something like Twitter's streaming API based on long-polling technique?
Am I in the right direction by assuming such kind of solutions or I'm totally missing the point?
Thanks in advance.
Giampaolo
I am working on something very similar myself.
So far i have the "loop" which can be set to any page, group or app on facebook.
SAMPLE: https://shawnsspace.com/plugins/wallfeed.php My page wall.
SAMPLE: https://shawnsspace.com/plugins/wallfeed.php?pageid=19292868552&ptype=feed&limit=40 Facebook Platform Wall.
With some perms, a form and user access_tokens i can make the wall postable. Asper UGLY - you do not need to run this in a loop, Facebook supports realtime updates and will send a response to your app when a user, or page has made a change.
MORE: http://developers.facebook.com/docs/api/realtime
Thanks for the input.
I tried to use the real-time API by using object=user and fields=feed.
If I understood the doc correctly this should result in my callback url being called (POST) every time a user writes something on my app's wall.
I received the initial GET request but never POST.
This is the current configuration:
{
"data": [
{
"object": "user",
"callback_url": "http://XXX.XXX.XXX.XX:8888/",
"fields": [
"feed"
],
"active": true
},
{
"object": "page",
"callback_url": "http://XXX.XXX.XXX.XX:8888/",
"fields": [
"picture"
],
"active": true
}
]
}
I've noticed various user comments reporting different concerns about the reliability of this API.
Also, here:
http://developers.facebook.com/docs/reference/api/page/
it says: "Note: Real-time updates are not yet supported for the total number of Page checkins."
...which I'm not sure what it means exactly.
For the record, my app's page I'm using for tests is:
http://www.facebook.com/pages/testgiamp/187148861354102?sk=wall