Facebook app configuration to generate reports for my clients - facebook

I created a really simple Facebook app that simply executes FacebookRequests and retrieves impressions, insights, and post data.
I had to create a Facebook app b/c in order for me to make these requests- I needed an APP ID and an APP SECRET.
I'd like to be able to easily generate reports for my clients' Facebook accounts that I do not directly manage.
What is the best/easiest way for my clients to accept/allow this app's usage? I don't want a page tab on my clients' accounts, either. I don't want to broadcast that they are utilizing this service that I setup.
Thanks,
Mike

The solution that worked for me was manually building a login flow per Facebook's documention.
Once the user authorized my app- it was successfully listed under their [Settings | Apps] section. Since this user managed the Facebook Page, I could execute FacebookRequests and retrieve impressions, insights, and post data that I had mentioned in my question with the page ID and the access token that the login dialog response provided.

Related

Seeing Facebook page through a test user

I want to integrate a Facebook page to ServiceNow.
I created a page with my personal account and an app on developers.facebook.com to extend my access token for 60 days. I made the REST connection successfully and was able to pull the posts and comments on that page into the database of the ServiceNow table.
Subsequently, my profile was blocked for a couple of days and I was informed the app that I made was violating certain Facebook policies. But after submitting the ID, it got reactivated. Then I made some test users so that I could comment on any post of that page to check if that comes into the ITSM database.
However, when I login through a test user, I cannot see the Facebook page associated with my personal Facebook profile.
I need to know how can I see posts of my page through a test user and comment on them. Do I need to provide any specific role to the test user for the same?

how to request permission to post ads on a page as an app?

I'm working on a facebook app that posts newsfeed ads, and I have been banging my head against the wall for the last few days, the work flow should go like this:
User provides his page id.
The App requests authorization to post ads on the page. stuck here
App verifies that the user authorized it.
App creates adcreatives using the user's page_id in the object_story_spec call to /adcreative using the app's ad account.
I went through How to post to page as an app?'s docs, couldn't figure it out.
the app is written in Go, however if you can provide a code sample it doesn't matter what language you use, I just need the basic work flow.
Not sure what you want to do exactly, but if you want to create ads (for am ad_account/user) via an app, you'll need the ads_management permission during Facebook Login.
How you manually create a login flow can be found in the docs as well.
See
https://developers.facebook.com/docs/facebook-login/permissions#reference-extended
https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow

Is it possible to view/download the content of the POST done via my facebook application?

I have a scenario, where an authorised user through my application is posting status/uploading pictures via my application by granting required permissions. My application uses graph APIs.
Now, as app administrator if I want to see the content of the post, that the user has uploaded via my application. How do i do it?
I know in graph APIs, I have INSIGHTS api. But, it just gives us the statistics of the posts done via my app or user.
Can i really see the posts?
Assuming as an app admin I only have app access token and app ID. I dont store user access tokens with me.
Actually, I worked on the problem with every possible way. Found out that, even being an APP administrator I will need user access token (stored with me), without which these data shall not be retrieved via APIs.
My need was not to use user access token; But, no Its not possible via APIs as of now.

Facebook connect and account remove

I have a website where users can log in with the Facebook oAuth API.
Once the user logs in or registers via Facebook it is stored in my database.
But what I'd like to achieve is, once the user goes to his Facebook application settings page and removes my website app permissions, the used should also be deleted from my database.
Is there any work around to this problem, if this is not possible via the Facebook oAuth API?
You can add Deauthorise Callback URL by Navigating to Settings > Advanced section of your application. Whenever a User Deauthorises your Facebook app, Facebook performs a HTTP POST of signed request to your URL. You may use the field user_id to determine which User has deauthorised your app.
Actually, I would do the following:
Add a date to his last log in to your site.
Have cron job check for old, unused accounts.
Send an email to the user's email address (or Facebook message mail) telling him his account is due to expire soon.
Delete account from database.

Downloading Facebook ads statistics in background (no web browser)

I am developing a backoffice server application wich is supposed to email our customers with ads campaign statitistics, where camapaigns are bundled from various providers, one of them being Facebook.
Now the problem is how to download specific ads campaigns from Facebook. Basically what I need is a table for specific campaign with values for impressions and clicks for each day from requested range.
One problem is that the application is background server process, running periodically without user interactions, so I suspect there could be a problem with authentication.
From what I have read so far, I believe I am supposed to
register my application on facebook
apply for Ads API access (?)
use either legacy REST API to get statistics, or perhaps adsstatistics from graph api (but I believe that the format there is not divided for particular days).
How am I supposed to authenticate in this case?
Any suggestion as to what is the right solution here?
(Note: In the past, I was doing similiar for Google, where I have successfully used http://code.google.com/intl/cs/apis/adwords/docs/guides/reporting.html - this is just for reference about what I need to achieve).
See this page for authentication once you have Ads API access:
http://developers.facebook.com/docs/authentication/
In the end you'll need an access_token which is specific to your application and the Facebook account you are accessing.
Here's our process:
Log into Facebook account that contains the ads data
Paste this into that browser's address bar:
https://www.facebook.com/dialog/oauth?client_id={your_application_id}&scope=ads_management,offline_access,read_insights&redirect_uri={your
website}
You should be taken to a page that allows you to
authorize your application for that Facebook account (green
Allow button)
Copy the authorization code that appears after code= in the redirected url
Paste this into that browser's address bar (you may not have a client_secret with your application, if you don't try this without the client_secret):
https://graph.facebook.com/oauth/access_token?client_id={your_application_id}&redirect_uri={your website}&client_secret={your application secret}&code={code you got
from step 4}
You should be taken to a page containing the access_token
I do not think you need to store the Authorization code since the access_token shouldn't expire (if you requested offline_access) unless the log in info is changed for the Facebook Account.
Stats Retrieval
For stats retrieval, I would not use legacy REST API since Facebook will depreciate it. Graph API does allow stats retrieval by day, use:
GET https://graph.facebook.com/stats/{starttime}/{endtime}/stats?ids={campaign_id}&access_token=...
starttime and endtime can be in YYYY-MM-DD HH:MM:SS format or as a unix (epoch?) time