How to create a pipeline in Matillion Data Loader from Facebook Content Insights? - facebook-graph-api

I am unable to create a pipeline to get data from Facebook Content Insights to Snowflake. I have generated the page access token from Facebook graph explorer & added that as a parameter- "OAuthAccessToken".
Error-
#434 [Query Facebook] - Parameter Validation Failure:
SQL Query - [190] (#190) This method must be called with a Page Access Token.
Can someone please help?
Thanks

Related

How to get a valid access token to query search result from Facebook graph API

I want to collect all the Facebook link from Facebook search function. What I'm using here is the Facebook graph API tool.
If I want to query the data for a keyword, for example: "limited";
I will use the URL:
https://graph.facebook.com/v11.0/search?q=limited&access_token={my_access_token}
My image
However, I got the result as in the image. When I tried to create a workplace app and tried to get the access token of that app, I got the message as in the second image.
Error message when getting the access token of a workplace app
What I need now is an access token that has the permission to retrieve the data from the Facebook search. After that, I can use python to handle the rest.
Please help me out, thank you very much!

Tokens : Access token issues by a user

Folks,
I am trying to figure out a way to get the list of the users that are using Google Drive for desktop in our Google workspace environment. Since there is no direct way of getting this information, i found an article online where one get this info by following the steps below:
List all the users of your domain
(https://developers.google.com/admin-sdk/directory/reference/rest/v1/users/list)
Check for each user, based on client id, what is the response
received using tokens: get
(https://developers.google.com/admin-sdk/directory/reference/rest/v1/tokens/get)
I was successful in getting the list of users but need help on how to get information around the token response for each user( I have the app client ID). Can someone help?

Facebook API - How to add a new Admin to a facebook Page using graph API?

I am trying to add a new Admin (facebook user) to a facebook Page using Graph API as shown in the screenshot but i get an error message:
"(#200) Either app or user doesn't have permission to modify admins."
When i check the access_token permissions it looks like i have everything in scope and still the request fails. Anyone has encountered this before?
Please check the attached screenshots.
Graph API request
Page AccessToken permissions

Instagram Graph API

My task is to get photo data of my business Instagram account with Instagram Graph API. I followed the instruction from Instagram Graph API -
https://developers.facebook.com/docs/instagram-api/reference/user/media
, which said request like
GET http://graph.facebook.com/17841405822304914/media
can get photo data from the Instagram account linked to the FB account in JSON format.
I tried to send GET request /my_facebook_id/media as said by the document with Graph API Explorer on FB developer platform but it failed to return the data I want.
This is the error I got:
message: Tried accessing nonexisting field (media) on node type (User)
type: OAuthException code: 100
Does the message mean the media field doesn't exist in the FB user?
What is the meanIng of error code 100? I can't even see that in FB official document.
I tried to use the Instagram business account ID for this request but I got an error message said the user object doesn't exist
How to get the task done? Thanks!
I guess you have missed creating a Facebook business page and linking your Instagram Business account to it.
Here is the guide to setup : https://developers.facebook.com/docs/instagram-api/getting-started
If this was done correctly and still you're facing the error is because of a Facebook bug where your account doesn't get linked correctly.
Here : https://developers.facebook.com/support/bugs/177912116363088/?disable_redirect=0
Solution : Please disconnect your Instagram account from your page. Then, on Instagram app, in setting you will have to switch back to personal account and reconvert to a business account
Note : Switching to a personal account you will lose the insights of your media.
Once this is done you should be able to get instagram_business_account and post which you can run your query to fetch the media :
GET http://graph.facebook.com/you-instagram-business-account-id/media

Unable to find Facebook Page Insights using Page Access Token in RestFB

I have to develop an automated process for fetching my Facebook page insights. Since, Access token used for authentication purpose is temporary in nature. Therefore, I created a Facebook App and by providing all required permissions I generated a Page Access Token so that I could extend it's life-span.
Reference Link : Java + RestFB API: Getting fresh Page Access Token without messing with AppID, appSecret
The following is my piece of code :
FacebookClient fb=new DefaultFacebookClient(accesstoken,Version.VERSION_2_7);
Connection<Insight> insights =fb.fetchConnection("119456244790112/insights", Insight.class,Parameter.with("since", "2016-08-01"),Parameter.with("until", "2016-08-27"));
for (Insight insight : insights.getData())
if(insight.getName().equals("page_impressions") && (insight.getPeriod().equals("day")) )
System.out.println(insight.getName()+"\t"+insight.getPeriod()+"\t"+insight.getValues());
'accesstoken' is the short-life Page access-token obtained by following the mentioned link.
The following is the Exception Stack I'm getting :
Exception in thread "main"
com.restfb.exception.FacebookOAuthException: Received Facebook error
response of type OAuthException: Invalid query (code 3001, subcode
1504028) at
com.restfb.DefaultFacebookClient$DefaultGraphFacebookExceptionMapper.exceptionForTypeAndMessage(DefaultFacebookClient.java:1191)
at
com.restfb.DefaultFacebookClient.throwFacebookResponseStatusExceptionIfNecessary(DefaultFacebookClient.java:1117)
at
com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:1058)
at
com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:969)
at
com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:931)
at
com.restfb.DefaultFacebookClient.fetchConnection(DefaultFacebookClient.java:356)
at Main.main(Main.java:31)
Please help me finding the Page Insights using Page Access Token and hence extending it's life-span so that I could produce an automated process out of this. Thanks !
You asked two questions in one.
Extending an access token:
First, you need the user access token. Than extend it (Check the RestFB manual: http://restfb.com/documentation/#access-token-extend) and take the page access token for the page from /me/accounts. The page access token has an unlimited lifetime.
The OAuthException:
If you look at the error message of the exception you should see that the metric is missing. You nee to tell Facebook what metric you like to get. Check the Graph API Reference for valid metrics: https://developers.facebook.com/docs/graph-api/reference/v2.7/insights
Finally I got the success in pulling the Page Insights data using the 'Page Access Token' with extended life-span.
The following is the snippet for making the appropriate requests to Facebook :
Connection<Insight> insights =fbclient.fetchConnection("1388062484542431/insights/page_views/day", Insight.class,Parameter.with("since", "2016-08-01"),Parameter.with("until", "2016-08-30"));
If multiple Metrics need to be passed then we can do so by passing comma-separated names of the required Metrics.
Thanks.