How do I get user's checked-in places' categories? - facebook

I want to get logged in user's Check-ins along with the category of the place he has checked-in.
I tried to fetch the user likes and their categories and this is what worked for me - "/me/likes?fields=category"
Following is the response returned:
{
"data": [{
"name": "11 East Street Cafe",
"category": "Restaurant/Cafe",
"id": "94871278677"
},{
"name": "ABC DEF",
"category": "Politician",
"id": "177526890164"
}],
"paging": {
"cursors": {
"before": "NDkyMzg4OTc3NTYyMjk3",
"after": "MTc3NTI2ODkwMTY0"
}
}
}
For check-ins, I tried "/me/feed?with=location&fields=place,story" and it returns the checked in places list. It returns me following:
{
"data": [{
"place": {
"id": "117586118328311",
"name": "Carraba's",
"location": {
"city": "Ellicott City",
"country": "United States",
"latitude": 39.27153726574,
"longitude": -76.800542073324,
"state": "MD",
"zip": "21043"
}
},
"story": "ABC was at Carraba's.",
"id": "1533836476934935_1546360939015822"
}, {
"place": {
"id": "876737405718973",
"name": "Chipotle Mexican Grill",
"location": {
"city": "Baltimore",
"country": "United States",
"latitude": 39.2866707,
"longitude": -76.6196671,
"state": "MD",
"street": "300 W Pratt St",
"zip": "21201"
}
},
"story": "Aadya Extentia was at Chipotle Mexican Grill.",
"id": "1533836476934935_1546360502349199"
}],
"paging": {
"next": "https://graph.facebook.com/v2.5/1533836476934935/feed?fields=place,story&wi…WzlgXDpe8ZCV8kHWcO2aNxlARSpwIZByS9OWkU8VC3nj2E3VoiLkJNpy2ESOI1R7fHIOJQZDZD"
}
}
But it does not return the category of checked-in place. i.e. I want know if it is a restaurant, museum or stadium, etc.
How do I do it?
Thanks.

You can do this using Field Expansion:
/me/feed?with=location&fields=place{name,category},story
Edit: Looks like this is working for API version <= 2.4 only, but not any more with v2.5.
Edit #2: I filed a bug report to ask if this was deliberately removed, or if it is a bug. https://developers.facebook.com/bugs/1550467468600884/

Even though a Place is a Page, I can't successfully retrieve the category field through Field Expansion...
This can be done with a batch request, by using the output of the first query as input for the second query:
curl \
-F 'access_token={USER_ACCESS_TOKEN}' \
-F 'include_headers=false' \
-F 'batch=[{ "method":"GET","name":"get-places","relative_url":"me/feed?with=location&fields=place{id,name,location},story&limit=100", "omit_response_on_success": false },{"method":"GET","relative_url":"?ids={result=get-places:$.data.*.place.id}&fields=id,name,category"}]' \
https://graph.facebook.com
See
https://developers.facebook.com/docs/graph-api/reference/place/
https://developers.facebook.com/docs/graph-api/making-multiple-requests/

Related

Posting address to Sharepoint list via REST

maybe I'm blind but I can't find a documentation how I post an address to an address field on a Sharepoint list via REST.
I always receive an "invalid Request" error. If I remove the address part of my JSON I'm able to fill out the other fields w/o problems. Just struggling with the address.
My request looks like that:
POST:
https://graph.microsoft.com/v1.0/sites/test.sharepoint.com,{siteid}/lists/{listid}/items/
Data:
{
"__metadata": {
"type": "SP.Data.listname.ListItem"
},
"fields":{
"Title": "API Test Project",
"Projekt_ID": "25",
"Typ": "Hinzugefügt",
"MengeNeu": "50/40/330",
"PosNr": "5/4/1",
"Adresse": {
"address": {
"city": "city",
"countryOrRegion": "DE",
"postalCode": "55512",
"state": "test",
"street": "test street 3"
},
"coordinates": {
"latitude": 44.72789001464844,
"longitude": 10.132317543029785
},
"displayName": "Test",
"locationUri": "https://www.bingapis.com/api/v6/localbusinesses/xxx?setLang=de",
"uniqueId": "https://www.bingapis.com/api/v6/localbusinesses/xxx?setLang=de"
}
}
}
Thanks

MongoDB - MongoImport of JSON (jsonl) - Rename, change types and add fields

i'm new to the topic MongoDB and have 4 different problems importing a big (16GB) file (jsonl) into my MongoDB (simple PSA-Cluster).
Below attached you will find a sample entry from the mentiond JSON-Dump.
With this file which i get from an external provider I actually have 4 problems.
"hotel_id" is the key and should normally be (re-)named as "_id"
"hotel_id" should not be treated as string rather than as Number
"location" is not properly formatted (if i understood correctly the MongoDB Manual) as GeoJSON as it should be like
"location": {
"type": "Point",
"coordinates": [-93.26838,37.15845]
}
instead of
"location": {
"coordinates": {
"latitude": 37.15845,
"longitude": -93.26838
}
}
"dates" can this be used to efficiently update just the records which needs to be updated?
So my challenge is now to transform the data according to my needs before importing the data or at time of import, but in both cases of course as quickly as possible.
Therefore i searched a lot for hints and best practices, but i was not able to find a solution yet, maybe due to the fact that i'm a beginner with MongoDB.
I played around with "jq" to adjust the data and for example add the type which seems to be necessary for the location (point 3), but wasn't really successful.
cat dump.jsonl | ./bin/jq --arg typeOfField Point '.location + {type: $typeOfField}'
Beside that i was injecting a sample dump of round-about 500MB which took 1,5 mins when importing it the first time (empty database). If i run it in "upsert" mode it will take round-about 12 hours. So i was also wondering what is the best practice to import such a big JSON-dump?
Any help is appreciated!! :-)
Kind regards,
Lumpy
{
"hotel_id": "12345",
"name": "Test Hotel",
"address": {
"line_1": "123 Test St",
"line_2": "Apt A",
"city": "Test City",
},
"ratings": {
"property": {
"rating": "3.5",
"type": "Star"
},
"guest": {
"count": 48382,
"average": "3.1"
}
},
"location": {
"coordinates": {
"latitude": 22.54845,
"longitude": -90.11838
}
},
"phone": "555-0153",
"fax": "555-7249",
"category": {
"id": 1,
"name": "Hotel"
},
"rank": 42,
"dates": {
"added": "1998-07-19T05:00:00.000Z",
"updated": "2018-03-22T07:23:14.000Z"
},
"statistics": {
"11": {
"id": 11,
"name": "Total number of rooms - 220",
"value": "220"
},
"12": {
"id": 12,
"name": "Number of floors - 7",
"value": "7"
}
},
"chain": {
"id": -2,
"name": "Test Hotels"
},
"brand": {
"id": 2,
"name": "Test Brand"
}
}

facebook api: event url

lets say I know I have an event ID. I would like the event URL (to link users to it), but the graph API does not seem to have it (https://developers.facebook.com/docs/graph-api/reference/event/), for example if I use the command GET /v2.9/310917539364835 HTTP/1.1 the output is:
{
"description": "...",
"end_time": "2017-06-23T22:30:00+1000",
"name": "UQ Postgrad Masquerade Party (End of Semester)",
"place": {
"name": "Cloudland",
"location": {
"city": "Brisbane",
"country": "Australia",
"latitude": -27.45891,
"longitude": 153.0349699,
"state": "QLD",
"street": "641 Ann Street",
"zip": "4006"
},
"id": "103221159774910"
},
"start_time": "2017-06-23T19:30:00+1000",
"id": "310917539364835"
}
but there is not URL.
Thanks
after doing some searching, it turns out that the URL is:
facebook.com/ + ID
so in this example. facebook.com/310917539364835

Is it possible to get the country code of a user from Facebook's Graph API?

When i tried to get the current location of a user via FQL, Graph API returned something like this;
{
"data": [
{
"current_location": {
"city": "Izmir",
"state": "Izmir",
"country": "Turkey",
"zip": "",
"id": 107968765903327,
"name": "İzmir, Turkey"
}
}
]
}
Using the Graph ID above, i checked the location information from https://graph.facebook.com/107968765903327 and this time i get more data about the city;
{
"id": "107968765903327",
"name": "\u0130zmir, Turkey",
"link": "http://www.facebook.com/pages/\u0025C4\u0025B0zmir-Turkey/107968765903327",
"likes": 178460,
"category": "City",
"is_published": true,
"is_community_page": true,
"description": "\u003Cp>\u003Cb>Izmir\u003C/b> is a large ...",
"location": {
"latitude": 38.4072,
"longitude": 27.1503
},
"checkins": 9059,
"talking_about_count": 238710
}
But, as you see, there is no chance for the country code with these options. Any other suggestions?
reverse geocode could help
see https://developers.google.com/maps/documentation/geocoding/

How to Set Venue for Event using Graph API

When I create events, I've tried adding venue details similar to what it looks like below, but the venue information seems to be ignored. (I'm posting it to /me/events)
The event otherwise gets created successfully. How can I set the venue during the creation process? Do I need to create it afterwards instead? Thanks
{
"owner": {
"name": "David R",
"id": "234234"
},
"name": "sdf",
"description": "tes",
"start_time": "2011-09-11T00:00:00",
"end_time": "2011-09-11T03:00:00",
"location": "sadf",
"venue": {
"street": "weber",
"city": "Waterloo",
"state": "Ontario",
"country": "Canada"
},
"privacy": "SECRET",
"updated_time": "2011-09-10T23:22:23+0000",
"type": "event"
}
get rid of '"venue"{}' and just use city state country etc..
{'name':"neverland",
'city':"los angeles",
'description':"ontherparty",
'location':"sames",
'start_time': "9-12-2011 12:45"
}