Get demographic info from audience insight group from Facebook marketing API - facebook

I'm trying to get demographic audience data from the Facebook Marketing API.
If I do this search I only get audience size:-
6003024075156?fields=audience_size,description,name,topic,disambiguation_category
which returns
{
"audience_size": 2824330,
"description": null,
"name": "Air New Zealand",
"topic": "Business and industry",
"disambiguation_category": "Airline Company",
"id": "6003024075156"
}
In the documentation it suggests I can get other info as seen in the main audience insights panel in Business Manager
https://developers.facebook.com/docs/graph-api/reference/audience-insights-query/
I'm particularly interested in knowing how to construct the query to return the demographic info of the audience
https://developers.facebook.com/docs/graph-api/reference/audience-insights-age-gender/
Field Description
age_by_gender
list<AudienceInsightsAgeGender>
Demographic information by gender

I think what you want should be here:
https://developers.facebook.com/docs/marketing-api/audiences-api/audience-insights-api/v2.8
However, the lock icon beside it suggests to me that no such API exists. This is probably due to the fact that Facebook uses a third party (http://www.acxiom.com/) to acquire the aggregate demographic data.

Related

Retreiving facebook comments by API

I would like to maintain a copy of all Facebook comments on my business page for analysis purposes.
I created an app and tokens and managed to query all posts on the page by this call
https://graph.facebook.com/v11.0/{page-id}/feed?access_token={token}
And for every post I can get the full comments by this call:
https://graph.facebook.com/v11.0/{object-id}/comments?summary=1&filter=stream&order=reverse_chronological&access_token={token}
That worked great but I have two problems:
I would like to retrieve all new comments on all posts. My page has 500+ posts. It would be very wasteful to query each of the 500 pages on daily basis to get all comments because 490+ of them will probably have no new comments on an any given day.
The results from the comment API call is very basis and does not provide the user name like the below sample
{
"data": [
{
"created_time": "2021-06-10T23:52:09+0000",
"message": "test 3",
"id": "xxxx_xxxx"
},
Is there a way to retrieve all comments regardless of the page and provide more info in the result? There are commercial tools that perform similar functionality like Sudota so theoritcally it should be possible but I could not find that in the API documentation.

Implementing tripadvisor traveller rating

my goal is to show TripAdvisor score rank inside my app alongside other ranking system. Keep in mind that my application is a B2B app, not B2C.
What i can not understand even after reading the developer documentation is what kind of API should i eventually ask for.
The Content API is only for B2C purposes...but, apparently, it is the only one that send me in response the actual TripAdvisor rating (the only thing i actually want from all TripAdvisor information).
Has anyone implemented TripAdvisor in an OTA (online travel agency) application and can guide me on which APIs to request?
Thank you in advice
I have not implemented TripAdvisor ratings in a B2B system, but helped on a B2C project that used Tripadvisor data.
Your findings regarding Content API is correct, this is the only API where you find ratings.
Rating is TripAdvisor "selling point", so this data protected and can only be used by following their presentation terms. Check out how here: https://developer-tripadvisor.com/content-api/display-requirements/
You have 6 months implementation time and have to get Tripadvisor approval, or they cancel your API key. By using their API you commit not to store any data retrieved from their API.
Quick guide to use their API: https://developer-tripadvisor.com/content-api/documentation/
Call the locator_mapper to get possible location_id(s)
http://api.tripadvisor.com/api/partner/2.0/location_mapper/42.344978,-71.119030?key=[YOUR_KEY_HERE]-mapper&category=hotels&q=Beacon%20Townhouse%20Inn%201023
It returns a JSON with possible locations,
{
"data": [
{
"location_id": "89575",
Then call location with the id to get ratings: http://api.tripadvisor.com/api/partner/2.0/location/89575?key=[YOUR_KEY_HERE]
"review_rating_count": {
"1": "18",
"2": "22",
"3": "63",
"4": "269",
"5": "1408"
},
Use this data, together with the presentation and links back to tripadvisor to comply with their license.

Linkedin rest api to search people with name

Is there any LinkedIn Rest API available to search people with first and last name?
I am not able to find anything on their developer website.
I found this url from some other question: http://api.linkedin.com/v1/people-search:(people:(id))?first-name=bill&last-name=gates
But when I am trying to hit this url from APIGee REST console I am getting response as 403 permission denied. I am using oAuth with my LinkedIn account.
I am currently using free account on LinkedIn, is because of that.
Linked has closed its API some time ago. See a detailed announcement here.
You have to get Vetted API access from Linkedin in order to do People Search. For more information please look into this link
You can use LinkedIn Public Search Results Scraper API to achieve this.
Here is an example. Response for a profile found look like this:
{
"id": "jimmy-neutron-b914a91a5",
"name": "Jimmy Neutron",
"occupation": "Chief Executive Officer at NASA - National Aeronautics and Space Administration",
"location": "Houston, TX",
"last_job": "NASA - National Aeronautics and Space Administration",
"last_education": "Harvard University",
"thumbnail": "https://media-exp1.licdn.com/dms/image/C4D03AQE7YG6jwNNy2Q/profile-displayphoto-shrink_200_200/0/1584908070871?e=1620259200&v=beta&t=QJREJQLCsAIaDiQCOZJ6Nu6QoyUPWK8ytJAWU52icRU",
"link": "https://www.linkedin.com/in/jimmy-neutron-b914a91a5?trk=people-guest_people_search-card"
},
Now LinkedIn does not provide search people apis for the reason for data-stealing.
thanks

Displaying Different Copy / Images Based on the Number of Likes

We're working on developing a program that will (hopefully) automatically swap out creative with new creative once a certain like threshold is met (i.e. if 100 people like the page, something new appears). Can we add coding so our system is able to tell how many "likes" are generated? I know that the number of likes are displayed, I'm just not sure if there is a way for a program to actually read how many likes there are.
I don't see if in any of the Facebook attributes in the developer's platform.
What you'll have to do is acquire an access token for your page and then query the facebook platform for the number of likes periodically (possibly with a cron job of sorts).
You can read more about how to get the page access token at this URL
https://developers.facebook.com/docs/authentication/
Facebook has given us a great took to help us mine all the data it holds - its called the Graph API Explorer and with it you can see what data will be returned when you query the API. When you query the API with only the page_id you'll get a response similar to this :
{
"id": "XXXXXXXXX",
"name": "My Awesome Page",
"picture": "foo.jpg",
"link": "https://www.facebook.com/pages/XXXXXXXX",
"likes": 345,
"category": "Product/service",
"website": "XXXXXXX",
"founded": "2011",
"description": "...",
}
For more information about how to use the Graph API you can see this link :
https://developers.facebook.com/docs/reference/api/
Facebook does provide good documentation:
http://developers.facebook.com/docs/reference/api/page/
As you can see there, there is a field "likes" containing the number (count) of likes for a page.

Scope of Facebook API

I am trying to learn and create a Facebook API on the go. However, I haven't found any page on the developer pages that specifies the scope of the Facebook API in great detail. I understand public information can be accessed using Graph API. But at the same time understand that further access is possible, not sure how much though.
Is there anyway to access the 'Edit news feed options' of a user that authorizes an application?
I don't really understand what you mean by "scope", but the Graph API is not more than a series of URLs to contact the facebook servers with queries and obtain answers in form of JSON objects.
You can start learning by looking at the reference for the API here:
http://developers.facebook.com/docs/reference/api/
There are unofficial APIs for every language you can imagine, for example java: http://code.google.com/p/facebook-java-api/ , c#: http://facebooksdk.codeplex.com/ , etc.
To read the news feed, you can access it by:
https://graph.facebook.com/me/home?access_token=TOKEN (where TOKEN is the access token)
Fb will respond with a JSON object similar to the one pasted below.
{
"data": [
{
"id": "11111_1111111111,
"from": {
"name": "Name",
"id": "11111111"
},
"message": "SOME_MESSAGE",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/111111/posts/11111"
},
{
"name": "Like",
"link": "http://www.facebook.com/11111/posts/11111"
}
],
"type": "status",
"created_time": "2011-04-20T20:19:04+0000",
"updated_time": "2011-04-20T20:19:04+0000"
},
etc etc etc
],
"paging": {
"previous": "https://graph.facebook.com/me/home?access_token=TOKEN",
"next": "https://graph.facebook.com/me/home?access_token=TOKEN"
}
}
Having that, you can use the ID for the person or the message to perform new queries, as explained in the FB API page:
All of the objects in the Facebook
social graph are connected to each
other via relationships. Bret Taylor
is a fan of the Coca-Cola page, and
Bret Taylor and Arjun Banker are
friends. We call those relationships
connections in our API. You can
examine the connections between
objects using the URL structure
https://graph.facebook.com/ID/CONNECTION_TYPE.
The connections supported for people
and pages include:
Almost every information on FB is accessible through the Graph API, provided the user authorized the app with the rigth permissions:
http://developers.facebook.com/docs/authentication/permissions/