Need to pull Graph API JSON and successively narrow my results - javascript

Need to pull from the end point "fb_page_categories" which returns an array of all categories a page could fall under. Which looks like so:
GET graph.facebook.com
/fb_page_categories?
This returns something like so:
{
"data": [
{
"name": "Interest",
"fb_page_categories": [
{
"name": "Literary Arts",
"id": "856055631167537"
},
{
"name": "Performance Art",
"id": "756092301147942"
},
{
"name": "Performing Arts",
"id": "1758092431143387"
},
I then need to pull all of the results of certain specific "categories" that querying said end point returned, and finally filter those categories by proximity to current location. I'm new to java and have no idea where to even begin, or what that code would look like. Any advice, articles, Stack questions, Git projects, etc that can point me in the correct direction would be greatly appreciated. Thanks!

Facebook’s own Graph search for places can do this in a fashion. On Facebook your current location is implicit with being logged in.
First you should be aware that the list of page categories you referenced don’t all allow location. Only categories within the business and organization trees do so. (Facebook refers to this organization as a category taxonomy.)
For example, the ID for Restaurant is currently 273819889375819. So the search result for restaurants nearby would be found at this link.
Graph query for places on Facebook has many other modifiers and it appears there has been continuing development of this feature. After a significant splash a few years ago it appears they have stepped back from fully documenting its use.

Related

Correct format of JSON key for Qualtrics Web Service Query

I'm trying to use the Web Service component of a Qualtrics survey to get data from a mailing list based on an answer provided by the person completing. So they would select "Bob Jones" and then the Web Service would look at the mailing list to then populate the email address for Bob Jones.
I'm able to call the mailing list and see results successfully with the API token, however, any time I try to add a query, I get a return of "Unexpected json key provided"
How can I access a specific entry? The format of the returned list follows:
{
"result": {
"elements": [
{
"id": "abcdefghijk",
"firstName": "Bob",
"lastName": "Jones",
"email": "bobjones#stackoverflow.com",
"externalDataReference": "Jones, Bob",
"embeddedData": {
"PrimaryEmail": "bobjones#stackoverflow.com",
"DisplayName": "Jones, Bob"
},
"language": "null",
"unsubscribed": false,
"responseHistory": [],
"emailHistory": []
},
I'm attempting to add the query where it says Parameter to Web Service...:
I greatly apologize if this has been discussed already. I searched through as many questions as I could, and didn't find an answer to this. Hope someone will help!
The API you are trying to use doesn't accept query parameters and you can't use it to get data for a specific contact.
Whether you can do it at all depends on whether your account has XM Directory or Research Core Contacts. If you have Research Core Contacts, the only way to get data for a specific contact is by contact id. If you have XM Directory you can use the search API. See: https://api.qualtrics.com/api-reference/reference/contacts.json/paths/~1directories~1{directoryId}~1contacts~1search/post

How to get all google reviews using business api

I need all google reviews for particular location but I am unable to use business api from google. Here is url for get request
https://mybusiness.googleapis.com/v3/accounts/account_name/locations/location_name/reviews
Now my question is what is the value for param account_name and location_name
How can I get that.
Please answer with sample location example
I think first of all you need to white list your google my business api for whatever project you are working on in your project as its private api. Google my business api will work on the locations associated with your account so make sure you verified the LOCATIONS from any account you know. Then you can try out the api call you mentioned in OAuthplayground.
Follow steps mentioned in below documentation URL to set it up:
https://developers.google.com/my-business/content/prereqs
After the setup and etc you will automatically understand the account id and location id.
Also few more urls you can go to understand it better.
https://console.developers.google.com (here you will setup your project)
https://business.google.com/manage (here you will add/can see the locations - for which you need reviews)
https://developers.google.com/my-business/content/basic-setup (Steps after completing the prereq)
https://developers.google.com/oauthplayground (You will test the my
business api here after approval)
When you make a request to https://mybusiness.googleapis.com/v3/accounts it gives you a list of accounts. On those accounts they have a field called name. That field is accounts/account_name.
{
"state": {
"status": "UNVERIFIED"
},
"type": "PERSONAL",
"name": "accounts/1337",
"accountName": "example"
}
When you make a request to https://mybusiness.googleapis.com/v3/accounts/account_name/locations it gives you a list of locations. On those locations they have a field called name. That field is accounts/account_name/locations/location_name.
{
"locations": [
{
"languageCode": "en",
"openInfo": {
"status": "OPEN",
"canReopen": true
},
"name": "accounts/1337/locations/13161337",
...
}

Determine weather user liked a photo or not. Facebook Graph API v2.2

I am working on Facebook application (JS sdk), In this app user can post like/comment on a photo. For this activity, It is showing a like button at bottom of photo. But if user already liked particular photo then we don't show like button there. For this we need to know weather user already liked the photo or not. It is possible to know this using FQL
SELECT object_id,like_info,comment_info FROM photo WHERE object_id=343907262480651
And it returns a boolean flag data["like_info"]["user_likes"]
I am migrating my code from graph api v1.0 to v2.2. So FQL will is longer available.
I want solution in graph API 2.2 similar to user_likes flag. I searched a lot for this, but not getting what exactly i want. Is there any alternative way to achieve this?
Thanks.
To get the likes for an object, you make call to
/{object-id}/likes
If you want the total number as a field, you need to set the field summary=true
I'm trying to accomplish the exact thing. So far, I couldn't find any end point that will readily tell you whether the user has already liked the post or not. But one work around is to call the /{object-id}/likes end point that will return you something like below:
{
"data": [
{
"id": "808004209267865",
"name": "Kailey Nicole"
},
{
"id": "10204107012455593",
"name": "Brenda S. Coffelt"
}
],
"paging": {
"cursors": {
"before": "OTU1NzQ4ODQxMTIyNDEz",
"after": "MTAyMDQxMDcwMTI0NTU1OTM="
},
"next": "https://graph.facebook.com/v2.3/10151929326420059/likes?pretty=0&limit=25&after=MTAyMDQxMDcwMTI0NTU1OTM="
}
}
You can then easily look for the user id in this JSON array. If it exists that means the user likes the page otherwise not. However keep in mind that there can be pagination (in case of lot of likes), so you'd really have to keep using the next URL to exhaust all likes data.

Getting like and comment counts per post of facebook page by graph api version 2

I have been getting like and comment counts per post of facebook page/group feed call by graph api separately using FQL but as version 2 of graph api released fql no longer working to serve purpose.
So i have to find new ways to get comment and like counts per post of page feed display. I will make a separate call to get comment and like counts per post of the fb page as it may not be possible to get things in same page feed call(or it is?).
So, searching through google, i found following way using graph api call -
..page_id/feed?fields=likes.limit(1).summary(true){id},comments.limit(1).summary(true)&limit=10
Is this the best and error free way?? Also besides id and summary fields i also get created_time, paging, likes data by the above call which is unexpected and redundant, how do i exclude these additional fields?
So please any FB employee show me light on what is the best way to retrieve like and comment count per post of page/group feed using graph api version 2.
If you want to retrieve Likes and comments count of a post on FB you can achieve this by using Id of the post Like this
..Your_Post_ID?fields=likes.limit(0).summary(true),comments.limit(0).summary(true)
the result will contain
Total numbers of likes of the post, total numbers of comments of the post, post ID and post created time.
The result will be like this
{
"likes": {
"data": [
],
"summary": {
"total_count": 550
}
},
"comments": {
"data": [
],
"summary": {
"order": "chronological",
"total_count": 858
}
},
"created_time": "2014-10-12T05:38:48+0000",
"id": "Your_Post_ID"
}

Get SoundCloud Artist Page? (Round 2)

I'm still trying to write a function in JavaScript where the user can type in an artist, and it will return a link to that artist's SoundCloud page.
For example,
/artist beyonce --> https://soundcloud.com/beyoncemusic
But the SoundCloud URLS don't all act the same. For example,
/artist dave matthews band --> https://soundcloud.com/dave-matthews-band.
For this reason, I can't simply just output scLink/artistName because they all have different URLs. I'm using Node.js, so I looked through a lot of npm packages, but couldn't figure out how to use any for this purpose. Perhaps Soundclouder will work somehow (though I couldn't figure it out myself). Does anyone know how I could write a command like this?
You are using the SoundCloud API, right?
A simple HTTP request to the right API should return the data you want. For example:
http://api.soundcloud.com/users.json?q=beyonce
[
{
"id": 4293843,
"kind": "user",
"permalink": "beyoncemusic",
"username": "Beyoncé",
"uri": "http://api.soundcloud.com/users/4293843",
"permalink_url": "http://soundcloud.com/beyoncemusic",
"avatar_url": "http://i1.sndcdn.com/avatars-000036935308-a2acxy-large.jpg?435a760",
"country": "United States",
"full_name": "Beyoncé",
"description": "",
"city": "New York",
"discogs_name": null,
"myspace_name": "beyonce",
"website": "http://www.beyonceonline.com",
"website_title": "",
"online": false,
"track_count": 33,
"playlist_count": 2,
"plan": "Pro Plus",
"public_favorites_count": 0,
"followers_count": 478783,
"followings_count": 0,
"subscriptions": [
{
"product": {
"id": "creator-pro-unlimited",
"name": "Pro Unlimited"
}
}
]
},
...
]
...so you could just do results[0].permalink_url.
You can use the request module to make the HTTP request manually, or use soundclouder to handle SoundCloud API's authentication details.
Most of the above does not apply if you want to make the actual requests from a browser. (The question is tagged node.js, but it sounds like you want to do this from a web page.)
If you're doing this from a webpage, use the SoundCloud JS SDK. The data you get back will look like the example above.
I don't think you'd be able to get an exact match reliably. Your best bet would be to search for users with the string you are looking for - example: "beyonce" and then to show the results and let them pick the correct link. You may be able to filter out likely results with follower count (high follower count) or something after you've pulled the initial list from soundcloud.
Search code:
users = SC.get('/users', { q: 'beyonce' });
Then iterate over users and display the permalink url. Hope this helps.

Categories