Custom facebook integration with .net - facebook

Am trying to create a facebook plugin for a desktop application that we have, and this app will only be used by 1 facebook account to post results from it to the facebook page of the app.
It would be submitting on behalf of the app and not the user , so no user login is needed ( Except for the original user who manages the page )
The problem I'm having is to review a submission with new permissions, facebook requires screenshots of the app running, how do I get that, if I don't have permissions to actually use those features, I tried to create a test user with the "manage_pages" permission and I get an error.

Thanks to #WizKid , I wasn't aware of that, I was able to generate a token with the permission needed from the graph explorer ( I chose my app from the dropdown ) , and from within my app, I call graph api to exchange the short lived token for a long lived token that lasts "hopefully" 60 days , also need the app id and secret, and I was good to go

Related

Is there another way to post automatically to my own Facebook page than using a long-lived page access token hardcoded into my code?

I am an admin of a Facebook page where I could post automatically an URL and a message every morning via a Python script for several months.
So far I used Facebook Graph API via a daily-ran Python script for this purpose with a never-expiring Page Access Token having manage_pages and publish_pages permissions. To obtain such an access token I followed a description similar to this. According to its steps I had to create an app on https://developers.facebook.com/apps. Finally I succeeded.
My Python code (including the never-expiring page access token) to post automatically on my Facebook page looked similar to this:
import urllib.request, urllib.parse
def fb_auto_post():
page_id = 'page_id_of_my_page'
page_access_token = 'never-expiring_page_access_token_of_my_page'
message = 'my_message' #(string) automatically generated by a previous function based on analyzing some daily data
link = 'my_link'
to_graph_API = 'https://graph.facebook.com/' + page_id + '/feed?message=' + urllib.parse.quote(message) + '&link=' + link + '&method=POST&access_token=' + page_access_token
urllib.request.urlopen(to_graph_API)
fb_auto_post()
This code worked fine for several months but now Facebook is performing an app review where my app failed and didn’t get approval for manage_pages and publish_pages permissions which both are required to continue posting automatically on my page. As a result I cannot use the above code anymore since my page access token has no permission to post to my page.
Now I am stuck and have two questions:
1:
I understand that Facebook will no longer let apps automatically post to their users’ timelines or pages and that's why my app did not get the required permissions. But is there an exception if the only page I want to post to automatically is my own? For example I found this quote in a manual:
"Your app might not need to request these permissions because people
posting are already set up with a role in your app's dashboard. If
this is the case you do not need to submit your app for review. See
the Roles tab in App Dashboard."
Since I am the admin of the app and also the admin of the only page I want to post to I think the quote fits to my case but I couldn't figure out how can I implement the exception described in it.
2:
The only reason I have created an app is to generate a long-lived page access token which I can insert into my Python code. Is there a way to bypass using a Facebook App? For example, is it possible to somehow automatically generate a short-lived page access token every morning via the Graph API? (As I’ve experienced, short-lived page access tokens still have the mage_pages and publish_pages permissions.)
Sorry for the very long problem description and thank you for your answers!
You can create a second application, not auditing, temporary use, waiting for the first application to be successfully audited, switching to a new permanent access_token

Auto Posting to Multiple Facebook Pages using Graph API - Auth Issues

I am pulling my hair out trying to understand what Facebook wants me to do to post to a FaceBook Page as a System User that has Admin and Page Privileges to and Owned by our business (We have Facebook Business Manager).
In a nut shell all I want to do is make this call:
https://graph.facebook.com/v2.5/${MyPageID}/feed
What I don't get is the access_token part.
I can generate access tokes for Apps, for Pages but all result in 403 returned from FaceBook. I have gone as far and checking every box available on the generate access token popup on the graph api and still I get 403 "Forbidden" so I am detailing the little I understand of the insanity that is FaceBook Auth in the hope that someone can explain where I am going wrong.
1) To Post as a System User to a Page I have to Create a FB App (I Would prefer just to post direct to the pages and skip the App part, My System User has Admin Access on All pages)
2) To Access the App I need an App Token.
3) To Create an App token I need a User Token.
4) To Create a user token I need to log in to Facebook and have all sorts of permissions on the App. (I can't log in as the System User! FB asks me to login as myself. I am not sure if this breaks the Auth Token generated?)
5) Then there are all sorts of swapping tokens to get a Permanent App token, Another point of potential failure!
6) IF the stars and moon align and you stand on your head the permanent App key can be passed to the above call as the access_token
I don't understand how to link the Pages I want to post to with the App created. Do I have to have 1 App for Each Page?
I have got one page to work, We initially used that App to Auth against the Instant Article Graph API:
https://graph.facebook.com/v2.5/${MyPageID}/instant_articles
I could not use the above token for the /feed url, I had to generate a new token with extra publish permissions and the page published with no problems, however when I change the ${MyPageID} to another page using the same access_token I get the 403.
I tried Creating a new App, I have no clue how they link to a specific page So the App to me seems sort of redundant.
Any help with what I am doing wrong or how I can go about simply posting to various FB Pages with a System User using the /feed api ?
The calls are made form a Spring Boot Java APP using HTTP Posts.
How to get a System User Auth and Page Auth:
1) Generate a User Token for an App (Button above the System User):
https://business.facebook.com/settings/system-users/${System User ID}?business_id=${your_business_manager_id}
System user has Page Admin on each page you need to post to.
App is just an FB app, not sure what it does other that it is a grouping I generate a token against.
I chose: (manage_pages, publish_pages, publish_actions, pages_manage_instant_articles, pages_show_list)
2) Check your access token:
https://developers.facebook.com/tools/debug/accesstoken/?access_token=${The access token you got from the step above}&version=v2.12
This will provide you with the App ID the Token is for and how long it lasts (we need a Permanent token)
3) Using Graph API Explorer gets the Accounts this token has access to:
https://developers.facebook.com/tools/explorer/${Your FB APP ID}/?method=GET&path=me%2Faccounts&version=v2.12
4) Using the output above find Page Auth for each page you wan to publish to
5) Post to each page in turn:
https://graph.facebook.com/v2.5/${MyPageID}/feed

Do review required if we want to get Facebook Page like count (Without Facebook login) by Facebook app token?

I am doing a static web page in my website, in which I am showing the like count of particular Facebook page. There is no kind of login required to see this web page. Also, I don't want to user to login with their Facebook account to see the Facebook page like count.
I have implemented this requirement by using Facebook app token.
API: "https://graph.facebook.com/PAGE_ID?access_token=APP_TOKEN"
But the problem here is, If I use the app token of already approved app by Facebook with some permissions (manage_pages) exists, it works. It is not working for the app token of newly created Facebook app.
I have sent the app for review to Facebook by requesting manage_pages permission, but they rejected the app and said that my website doesn't have the Facebook login functionality implemented.
Since it is not documented clearly, I have a doubt that do the app need to send for review if I want to get the Facebook page like count without Facebook login (By using Facebook app token)? If yes, what permission do I want to request?
Any help would be much appreciated.
First of all, you need to learn what Tokens there are:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/
For your problem, you can just use an App Access Token. There is no need for any permission or Login Review, the links above tell you exactly how to create one. Make sure you never use the Token on the client, especially because it includes the App Secret. Do the API call on the server only (file_get_contents or curl, if you use PHP).
If by "it does not work" you mean that you only get the id and the name, then it´s not about "not working", you need to read the changelog and search for "Declarative Fields": https://developers.facebook.com/docs/apps/changelog#v2_4
So if you want to get more than just id and name, the API call would be like this: https://graph.facebook.com/936299239766048?access_token=YOURAPPTOKEN&fields=id,name,likes,...

Automatic post to my facebook page from Node.js server

I have a Node.js server running a social network site and I also have a facebook page for that site. For certain actions performed by users on my site, I want to post details on the facebook page of my app.
I referred to Thuzi facebook node sdk here on how to post to facebook wall. However, it requires app id, app secret and a temporary access token. App id and app secret are constant so I can put them somewhere in my config file and use from there. But how do I get the access token without any interaction from front-end ? All posts will be published by our app only and that too on our own page. I just want this to be triggered by the end user's actions. Any help ?
I am using Sails.js framework btw.
You would need to use an Extended Page Token for that, you only need to create it once and it will stay valid forever. And you will post "as Page" with a Page Token. How to get an Extended Page Token:
Create an App
Use the Graph API Explorer to generate a User Access Token (by authorizing the App with the manage_pages and publish_actions permission)
Extend the User Access Token (valid for 60 days)
Request an Extended Page Token by calling /me/accounts
Store that Extended Page Token on your server and use it for posting on the Page wall.
Here are some additional resources, explaining everything in detail:
https://developers.facebook.com/docs/facebook-login/access-tokens/
https://developers.facebook.com/docs/graph-api/reference/v2.1/page/feed
http://www.devils-heaven.com/facebook-access-tokens/
http://www.devils-heaven.com/extended-page-access-tokens-curl/
I am also digging more in to this nowdays As I am working on a node module for this.
Till now I got to know that we can create a temporary access_token and we can than extend that token upto max 60 days.
For this after getting temporary token you need to make a call to this url to get a access token with 60 days validity.
https://graph.facebook.com/oauth/access_token?client_id=&client_secret=&grant_type=fb_exchange_token&fb_exchange_token=

How to notify users peridocally from an app

So there's an app, let's say it's an app that is capable of delivering relevant news based on the user's choice done the first time he runs the app. Is there a way to post the news to the user's wall without having the user to be online and ideally as the app?
So on his/hers timeline it would look like this (edited image, not a real post from some app, it's just so you get what I mean):
When I use $facebook->api('/me', 'post'), it just creates a post as the user, which is not what I want and does not allow me to post when the user is not logged in.
You can use the server side authentication to get a long lived access token (60 days) which you can then use until the token times out. Then you'll need to have the user reengage with your app to get a new token.
You can get the same thing by using the client side authentication and then extending the token on the server side.
Another options which should work for you is to get an app access token (which does not expire) and ask the user for the publish_stream permission, then:
App access tokens can also be used to publish content to Facebook on
behalf of a user who has granted a publishing permission to your
application.