How to Set Venue for Event using Graph API - facebook

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"
}

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

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

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

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/

Getting facebook place id from instagram place

I know from the documentation of the instagram API that instagram has facebook locations mapped so you can search and get the location detail from instagram via facebook place id i.e.
https://api.instagram.com/v1/locations/search?facebook_places_id=273471170716&access_token=[ACCESS-TOKEN]
As you can see I am retreiving the location detail via facebook place id.
But in my scenario, what I want is to get facebook place id using instagram id from the instagram location detail. Below is what I mean:
I have got the instagram location id and can get the detail of the place using the following:
https://api.instagram.com/v1/locations/2862169?access_token=[ACCESS-TOKEN]
But the above call only returns the location name and geographic co-ordinates. Whereas I want the Facebook place id of the location as well. Is there any way for me to get the facebook place id from the instagram as well?
I have checked their documentation on Location endpoints (https://instagram.com/developer/endpoints/locations/) and wasn't able to find any relevant information.
The reason why I want that is, I need to get the location detail such as category etc as well which instagram API doesn't provide, so I plan on using this retrieved facebook place id on facebook graph API to retrieve this additional location details.
I think you can only use the Facebook Graph API search for this. Therefore, you can use the output from the Instagram API for latitude, longitude and name to construct a Graph API call which returns you a list of matching Facebook Place Pages.
If the Instagram location id is 788029 for example, the API will return the following JSON:
{
"id": "788029",
"latitude": 48.858844300000001,
"longitude": 2.2943506,
"name": "Eiffel Tower, Paris"
}
So, if you take this result and use the data to construct a Facebook Graph API search url, it will result in something like this:
https://graph.facebook.com/search?q=Eiffel%20Tower,%20Paris&type=place&center=48.858844300000001,2.2943506&distance=100&limit=3&access_token={app_access_token}
You can choose the distance as well as the limit as you desire. If you set limit=1 you will only receive the place which Facebook deems to be the best match. Replace {app_access_token} with an actual App Access Token.
The Facebook response will be something like
{
"data": [
{
"category": "Local business",
"category_list": [
{
"id": "276651312419490",
"name": "Monument"
}
],
"location": {
"street": "",
"city": "Paris",
"state": "",
"country": "France",
"zip": "75007",
"latitude": 48.858385562198,
"longitude": 2.2944861654879,
"located_in": "141184112585566"
},
"name": "Level 2 Eiffel Tower, Paris",
"id": "380503552017025"
},
{
"category": "Local business",
"category_list": [
{
"id": "186825111351005",
"name": "Tourist Attraction"
}
],
"location": {
"street": "",
"city": "Paris",
"state": "",
"country": "France",
"zip": "",
"latitude": 48.858205346341,
"longitude": 2.2944900587791
},
"name": "Eiffel Tower Sommett, Paris, France",
"id": "1458706024363987"
},
{
"category": "Restaurant/cafe",
"category_list": [
{
"id": "168976549819329",
"name": "French Restaurant"
}
],
"location": {
"street": "",
"city": "Paris",
"state": "",
"country": "France",
"zip": "75007",
"latitude": 48.858532957713,
"longitude": 2.2941094631632,
"located_in": "141184112585566"
},
"name": "58 Tour Eiffel (officiel)",
"id": "148894855169991"
}
],
"paging": {
"next": "https://graph.facebook.com/v2.2/search?limit=3&type=place&q=Eiffel Tower, Paris&center=48.858844300000001,2.2943506&distance=100&offset=3&__after_id=enc_AdCYS3bVKOc29JFMrqlsouSZCvBxUTYZC7nHvqDHKAiBNrOs2ehUIaOsJ2wL9TxF9KOfgGmqEPOaLwotDM4pIUqyFf"
}
}
See
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#search
https://instagram.com/developer/endpoints/locations/

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/