How to query Facebook's graph API from an app instead of a page? - facebook-graph-api

Following my question (to which I self-answered): Is possible to use Facebook's (Page) Graph API without having an role in that page?
I would now like to know if I can get an access token for an app (created in https://developers.facebook.com/apps/) instead of a page (of which I can get an access token in Graph Explorer), to query Facebook's graph API?
e.g. with my page's (which is not the page I'm querying the graph about) access token:
GET https://graph.facebook.com/24HourFitness/posts?access_token=(*)
(*) access token generated in Graph Explorer (page access tokens) for one of the pages I admin

This is much too broad. It will always depend on WHAT you want to query with the App Access Token, because not all object allow using App Access Token, but require a User or Page Access Token...
Refer to the object's docs to see if it's possible for the purpose you desire, e.g.
https://developers.facebook.com/docs/graph-api/reference/page#Reading
says
Permissions
For pages that are published, you need:
An app or user access token to view fields from fully public pages.
A user access token to view fields from restricted pages that this person is able to view (such as those restrict to certain demographics like location or age, or those only viewable by Page admins).
A page access token can also be used to view those restricted fields.

Related

Accessing user_ID via messenger bot

I'm using the Graph API, but I can't figure out how to get a logged-in users ID address.
The intro to Graph states "The Graph API can provide access to all of the basic account registration data you would typically request in a sign-up form for your site, including name, email address, profile picture, and birthday" but to access them i need user_ID so how could i get it ?
https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Did%2Cname&version=v3.0
You need to have a token from the user, check out the given link. You can see what informations you can access if you give permission to your own profile.
This ID is unique to each app and cannot be used across different apps.

Facebook Graph API - Can't access some Pages

I am using an external server to retrieve events from multiple Facebook Pages. In about 1% of all cases, I get an error of the following type:
Unsupported get request. Object with ID '...' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api
The common link I've found between the Pages that aren't working is that they are kind of private: if you log out of Facebook, you can't access their page, even though you can access other pages.
I am using an App Access Token to do this. Is there a way to access these Pages' events anyway?
UPDATE
I've found some explanation in the Facebook Docs.
Permissions
For pages that are published, you need:
An app or user access token to view fields from fully public pages.
A user access token to view fields from restricted pages that this person is able to view (such as those restrict to certain demographics like location or age, or those only viewable by Page admins).
A page access token can also be used to view those restricted fields.
This probably means that these particular pages aren't "fully public pages". Is there still some work around?

Facebook Page Likes over time

I'm not the owner of a facebook page (eg. TESLA) but I'm trying to use graph api to get the number of user that liked the pages over time. Based on graphi api documentation (insight/page_fans), I'm just getting empty json documents. Any ideas how I can get this data?
Only two page-related metrics are available publicly, page_fans_country and page_storytellers_by_country.
Everything else is only accessible to an admin user of the page, resp. using a page access token.
You can not get the data you want for pages you do not have admin access to.

Is possible to use Facebook's (Page) Graph API without having an role in that page?

For example, let's say I need to "crawl" (not manually since it looks against Facebook's policies but via graph API) some information from a Facebook's brand page (e.g. https://www.facebook.com/nike/ ).
For example I may need to collect the following fields from a set of brand pages (not just one, such as the one mentioned above, for which I could definitely do it manually), when they are publicly available:
("About tab")
- description
- address
- website
- ...
I was reading Facebook's graph API docs and permissions.
However these permissions are related to users and I already worked with that. What I learned it that it works by
Facebook login --> auth the app to use my data --> the app has access to my data as a Facebook user.
However I'm now interested in brand pages for which I found this docs and this (access token). However it seems that to be able to use this access token I need to be a user with some role in the page (e.g. admin) and not any user who just liked that page.
So, is it possible to access brand pages' data (read-only, i.e. GET) via graph API without actually owning/admin/publishing on that page?
Apparently no "special" access token is required to access pages' public info.
For example I can create any page (not app) in my Facebook account and then use
GET https://graph.facebook.com/(*1)/feed?access_token=(*2)
(*1) the page's name (nike) or ID
(*2)my "bridge" page (i.e. empty page, only used to have an access token. not the page I'm using the graph api on)'s access token
Similarly for /posts/ etc.

FB G+ and Twitter integration and pushing posts

I was just wondering if an app exists for Django that helps connecting all 3 social networks, imports basic info, profile picture, but most importantly pushes the post user makes to these three website accounts. I looked into django-social-auth but that just lets you register or login with these websites,not push posts.
django-allauth http://github.com/pennersr/django-allauth/ stores basic info for FB/G/Tw (and more), provides basic access to the profile picture, and stores the access tokens in the database.
Whatever you do with the access token is project specific and beyond allauth scope. For example, in order to post to the users wall you need:
The user's permission (you can do this by configuring the proper scope for the Facebook provider, search for SCOPE in the README.txt)
Once the user is logged in via FB, the access token is stored in allauth.socialaccount.models.SocialToken. Simply lookup the token for the user that is logged in.
Then, given the token use whatever method you like to post to the Facebook API on behalf of the user. E.g. https://github.com/pythonforfacebook/facebook-sdk
For some more background on the relation between a Django user and the Social* models, see:
How can I get the user's facebook id with django-allauth?
There are django apps that do what you need individually (Facebook example), but I'm not aware of one that works with multiple.
django-social-auth will get you half way there by obtaining the users information and permission to post to the social network on their behalf.
Once you have users authenticating via django-social-auth you'll have access to the users access token needed to post to respective network on their behalf.
From there, you're going to have to stitch together some additional python modules like the Facebook example above to do the actual posting.