I'm trying to get the attending_count on facebook graph API. I know that going throug /event-id?fields=attending_count I will have this info available but when trying this inside the venue /venue-id/events?fields=attending_count this is not being displayed.
Here is what i'm trying:
https://graph.facebook.com/v2.2/217733628398158/events?fields=id,cover,name,venue,description,ticket_uri,start_time,attending_count&access_token=....
Any ideas?
There's no attending_count field on the Event object, but there is an attending edge:
https://developers.facebook.com/docs/graph-api/reference/v2.2/event#readfields
https://developers.facebook.com/docs/graph-api/reference/v2.2/event/attending#read
Why are you trying to get the attending_count on the Venue's Page ID? That doesn't make much sense.
You can use the summary to get the absolute count of attendees like this
/217733628398158/events?fields=id,cover,name,venue,description,ticket_uri,start_time,attending.summary(true).limit(1)
To reduce the amount of data returned by the Graph API I added the .limit(1) which is only returning one attendee per event, but producing the summary count anyway. If you need the whole list, remove the limit parameter.
So, it returns
{
"data": [
{
"id": "326299167565639",
"cover": {
"cover_id": "839491946113340",
"source": "https://scontent-a.xx.fbcdn.net/hphotos-xpa1/t31.0-8/s720x720/10547740_839491946113340_540194689313513221_o.jpg",
"offset_y": 28,
"offset_x": 0
},
"name": "Feeling This • Histórias de verão",
"venue": {
"name": "Lima e Silva, 1037, Porto Alegre"
},
"description": "ARE YOU FEELING THIS?\nÉ a nostalgia da estação quente que tá batendo!\n\nFaça aqui a sua história de verão.\nThese are the best days of our lives!\n\n-\n\nIngressos:\nR$15 com Feeling Cup!*\nR$20 na lista* <http://goo.gl/1I9vV8>\nR$25 na hora\n\n* Lista encerra às 20h do dia da festa. \n* Válido para entrada até 00h\n\n\nQuer comemorar seu aniversário na FEELING THIS? Entre em contato através do e-mail cucko#cucko.com.br para saber das vantagens.",
"ticket_uri": "https://www.facebook.com/ajax/events/ticket.php?event_id=326299167565639&source=12&ext=1421830108&hash=ATX8w7CCSBVhKO6G",
"start_time": "2015-02-04T22:00:00-0200",
"attending": {
"data": [
{
"name": "Foo Pretenders",
"rsvp_status": "attending",
"id": "1395261354109384"
}
],
"paging": {
"cursors": {
"after": "TVRBd01EQTROelkxT1RnMk9UYzBPakUwTWpNd09UUTBNREE2TVRZMU1EZzBPRGsyT0RRNE5UZ3g=",
"before": "TVRBd01EQTROelkxT1RnMk9UYzBPakUwTWpNd09UUTBNREE2TVRZMU1EZzBPRGsyT0RRNE5UZ3g="
},
"next": "https://graph.facebook.com/v2.2/326299167565639/attending?summary=true&limit=1&after=TVRBd01EQTROelkxT1RnMk9UYzBPakUwTWpNd09UUTBNREE2TVRZMU1EZzBPRGsyT0RRNE5UZ3g="
},
"summary": {
"count": 634
}
}
},
....
]
There are 634 people attending the specific event.
Related
I have the following iteration state defined in a Map State:
"WriteRteToDB": {
"Comment": "Write Rte to DB. Also records the risk calculations in the same table.",
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"End": true,
"Parameters": {
"FunctionName": "logger-lambda",
"RtInfo.$": "States.Array($)",
"ExecutionId.$": "$$.Execution.Id",
"InitTime.$": "$$.Execution.StartTime"
}
The parameters defined produce the following input:
{
"FunctionName": "logger-lambda",
"RtInfo": {
"status": 200,
"rte": {
"date": "2022-06-05 00:00:00",
"rt_value": 778129128.6631782,
"lower_80": 0,
"upper_80": 0.5,
"location_id": "WeWork Office Space & Coworking, Town Square, Alpharetta, GA, USA",
"syndrome": "Gastrointestinal"
}
},
"InitTime": "2022-06-05T15:04:57.297Z",
"ExecutionId": "arn:aws:states:us-east-1:1xxxxxxxxxx1:execution:RadaRx-rteForecast:0dbf2743-abb5-e0b6-56d0-2cc82a24e3b4"
}
But the following Error is produced:
{
"error": "States.Runtime",
"cause": "An error occurred while executing the state 'WriteRteToDB' (entered at the event id #28). The Parameters '{\"FunctionName\":\"logger-lambda\",\"RtInfo\":[{\"status\":200,\"rte\":{\"date\":\"2022-12-10 00:00:00\",\"rt_value\":1.3579795204795204,\"lower_80\":0,\"upper_80\":0.5,\"location_id\":\"Atlanta Tech Park, Technology Parkway, Peachtree Corners, GA, USA\",\"syndrome\":\"Influenza Like Illnesses\"}}],\"InitTime\":\"2022-06-05T16:06:10.132Z\",\"ExecutionId\":\"arn:aws:states:us-east-1:1xxxxxxxxxx1:execution:RadaRx-rteForecast:016a37f2-d01c-9bfd-dc3f-1288fb7c1af6\"}' could not be used to start the Task: [The field \"RtInfo\" is not supported by Step Functions]"
}
I have already tried wrapping the RtInfo inside an array of length 1 as you can observe from above, considering that it is a state within the Map State. I have also checked Input size to make sure that it does not cross the Max Input/Output quota of 256KB.
Your task's Parameters has incorrect syntax. Pass RtInfo and the other user-defined inputs under the Payload key:
"Parameters": {
"FunctionName": "logger-lambda",
"Payload": {
"RtInfo.$": "States.Array($)",
"ExecutionId.$": "$$.Execution.Id",
"InitTime.$": "$$.Execution.StartTime"
}
}
If you are reading this, you will read that you can add children to the fields query parameter. That means that if you have a media with the type "CAROUSEL_ALBUM" you will get the ids of the images as well.
Example CURL:
https://graph.instagram.com/me?access_token=<mytoken>&fields=id,media_type,media_url,children
The result:
...
"id": "some-id",
"media_type": "CAROUSEL_ALBUM",
"media_url": "some-url",
"children": {
"data": [
{
"id": "another-id"
},
{
"id": "other-id"
}
]
}
...
Is it possible to add media_url to the children's data? I don't really want to fetch everything in a loop...
#Mecha I did this for PHP, but maybe you can read this
/**
* Fetches media from the user
*
*/
public function fetchUserMedia(array $options, int $limit = 24): object
{
$query = http_build_query(array_merge([
'limit' => $limit,
'fields' => 'username,caption,id,media_type,media_url,thumbnail_url,children{media_url,thumbnail_url}',
'access_token' => $this->token
], $options));
return json_decode((string) ($this->client->get("https://graph.instagram.com/me/media?{$query}"))->getBody());
}
One output example is like this:
{
"caption": "I\u2018m addicted to chia pudding, how about you? \ud83d\ude0d Layers of zingy lemon vanilla chia pudding, mango thyme infused coconut yoghurt and juicy fresh mango roses. \ud83e\udd24\nMade by \u0040addictedtodates \ud83c\udf4b\u2063\u2063\n\u2063\u2063\u2800\nAND now to our tagged picture of today \ud83d\ude0b\ud83d\ude0b Swipe left to see \u0040smoothie_yumm\u2019s coconut vanilla smoothie bowl topped with turmeric chia pudding \ud83e\udd29\n\u2800\nYou can find the recipe on her page \ud83d\udc9b\n\u2800\n\ud83c\udf31 Tag #avidofood or\u00a0\u0040avidofood\u00a0to be featured in the future!\n\u2800\n\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\u22c6\n#vegan #veganfood #veganfoodie #veganfoodshare #vegatarisch #veganpasta #vegandinner #veganeats #healthyfood #plantbased #plantbasedfood #veganpower #plantbaseddiet #veganiseasy #whatveganseat #forksoverknives #vegetarianrecipes #veganinspo #vegetarian #veganism #veganmeals #veganlife #veganlifestyle #veganlove #veganmealprep #veganrecipes #veganhealth #veganlunch",
"id": "18039820117203997",
"media_type": "CAROUSEL_ALBUM",
"media_url": "https://scontent.xx.fbcdn.net/v/t51.2885-15/71511404_203552310658678_3865693276191599368_n.jpg?_nc_cat=100&_nc_oc=AQlet8stFGS32TTdBhXT4NNfpzd8eNq7oI0xilix4qyiVvt50avuk6RVotMgM-BUptmCrsVwLCGkPCc-sL7b-eAy&_nc_ht=scontent.xx&oh=f1a700b4d021d2d577d54cd74f4838fa&oe=5E534677",
"permalink": "https://www.instagram.com/p/B3-XRMOIWPW/",
"username": "avidofood",
"children": {
"data": [
{
"media_url": "https://scontent.xx.fbcdn.net/v/t51.2885-15/71511404_203552310658678_3865693276191599368_n.jpg?_nc_cat=100&_nc_oc=AQlet8stFGS32TTdBhXT4NNfpzd8eNq7oI0xilix4qyiVvt50avuk6RVotMgM-BUptmCrsVwLCGkPCc-sL7b-eAy&_nc_ht=scontent.xx&oh=f1a700b4d021d2d577d54cd74f4838fa&oe=5E534677",
"id": "18041124712207922"
},
{
"media_url": "https://scontent.xx.fbcdn.net/v/t51.2885-15/72483636_1251439178368296_6758852942587086206_n.jpg?_nc_cat=109&_nc_oc=AQmVrktP2g7Z72WifVdu4z17OzwM7ZNFLln1e1ZQxjdUi-j79Ttf-i840mjYkOb-TW3Dwm39Gyoe3EefxwB7UydW&_nc_ht=scontent.xx&oh=a07d3f51aa5eb5eb30697c4ad25d4e35&oe=5E60AEC3",
"id": "17851162897631131"
}
]
}
You just need to nest the fields in the children query params
/media?fields=id,media_url,children{media_url}&access_token=
I'm quite new to Python and programming in general, so apologies if this is quite basic or has been asked and answered before. Here is a sample of the data I'm working with:
{
"homeTeam": {
"formation": [
"4",
"4",
"2"
],
"lineupsSorted": [
{
"player": {
"name": "Scott P. Brown",
"slug": "scott-p-brown",
"shortName": "S. P. Brown",
"id": 19889,
"hasImage": true
},
"position": 1,
"shirtNumber": 1,
"substitute": false,
"positionName": "Goalkeeper",
"positionNameshort": "G",
"captain": false
},
{
"player": {
"name": "Carl Winchester",
"slug": "carl-winchester",
"shortName": "C. Winchester",
"id": 110785,
"hasImage": true
},
"position": 2,
"shirtNumber": 27,
"substitute": false,
"positionName": "Midfielder",
"positionNameshort": "M",
"captain": false
},
I am looking to automate populating defined names as I have done manually here:
hometeamPositions =['Goalkeeper','Midfielder','Defender','Defender','Defender','Midfielder','Midfielder','Midfielder','Midfielder','Forward','Forward','Goalkeeper','Defender','Defender','Midfielder','Midfielder','Forward','Forward']
hometeamPlayers = ['S. P. Brown','C. Winchester','M. Onariase','W.
Boyle','J. Cranston','H. Pell','J. Rowe','K. Storer','B. Waters','D.
Wright','D. Holman','R. Lovett','J. Barthram','T. Plavotic','J.
Munns','L. Davis','K. Wootton','J. Dayton']
As I will be repeating this process many hundreds of times with different data (same structure) I was wondering if anyone could give me some tips on automatically building these ranges?
Thanks,
Peter
I'm not sure I understood what is the problem you are trying to solve but I'll try to help.
Assuming you have a dictionary team_dict and you want to create 2 list: hometeamPositions and hometeamPlayers you can use the following code:
hometeamPlayers = []
hometeamPositions = []
for player_dict in teams_dict['homeTeam']['lineupsSorted']:
hometeamPlayers.append(player_dict['player']['shortName'])
hometeamPositions.append(player_dict['positionName'])
The output on your example will be:
hometeamPlayers = ['S. P. Brown', 'C. Winchester']
hometeamPositions = ['Goalkeeper', 'Midfielder']
I have a data element that can either be a Map or a List of Maps.
Here are two simplified data examples (expressed as JSON for readability)
1) Maps
{
"lom:general": {
"lom:title": {"lom:string": {
"language": "fr",
"content": "Premiers Pas avec un Progiciel de Gestion Intégré"
}},
"lom:language": "fr"
},
"lom:technical": {"lom:location": "http://hub11.ecolearning.eu/course/progiciel-metiers-pgi/"}
}
2) List of Maps
{
"lom:general": {
"lom:title": {"lom:string": [
{
"language": "fr",
"content": "DIY Education aux médias et à l'information - 3ed"
},
{
"language": "en",
"content": "DIY Media and Information Literacy - 3ed"
}
]},
"lom:language": [
"fr",
"en"
]
},
"lom:technical": {"lom:location": "http://hub5.ecolearning.eu/course/diy-do-it-yourself/"}
}
I want to check the type of element lom:general.lom:title.lom:string and iterate it if it is a list.
I have tried the following:
<title>
<#assign titles = lom\:general.lom\:title.lom\:string>
<#if titles?is_enumerable>
<#list titles as title>
<string language="${title.language}">${title.content}</string>
</#list>
<#else>
<string language="${titles.language}">${titles.content}</string>
</#if>
</title>
The template works as expected with the first data example. However, the second data example raises a StackOverflowError
java.lang.StackOverflowError
at sun.reflect.misc.ReflectUtil.checkPackageAccess(ReflectUtil.java:188)
at sun.reflect.misc.ReflectUtil.checkPackageAccess(ReflectUtil.java:164)
at sun.reflect.generics.reflectiveObjects.TypeVariableImpl.getGenericDeclaration(TypeVariableImpl.java:164)
at sun.reflect.generics.reflectiveObjects.TypeVariableImpl.equals(TypeVariableImpl.java:189)
at com.sun.beans.TypeResolver.resolve(TypeResolver.java:190)
at com.sun.beans.TypeResolver.resolve(TypeResolver.java:201)
Where the last line is repeated dozens of times
I want to get the realtime facebook sharecounts for each url in my site so I can display it.
I found two ways:
using the facebook restserver.php like this:
http://api.facebook.com/restserver.php?method=links.getStats&urls=https://www.daltravel.ro/circuit/Circuit-Anglia-Scotia-Irlanda
And it returns this:
<links_getStats_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
<link_stat>
<url>
https://www.daltravel.ro/circuit/Circuit-Anglia-Scotia-Irlanda
</url>
<normalized_url>
https://www.daltravel.ro/circuit/Circuit-Anglia-Scotia-Irlanda
</normalized_url>
<share_count>0</share_count>
<like_count>0</like_count>
<comment_count>0</comment_count>
<total_count>0</total_count>
<click_count>0</click_count>
<comments_fbid>1084234134929324</comments_fbid>
<commentsbox_count>0</commentsbox_count>
</link_stat>
</links_getStats_response>
Using the garph api, like this:
https://graph.facebook.com/v2.5/https://www.daltravel.ro/circuit/Circuit-Anglia-Scotia-Irlanda?access_token=ACCESS_TOKEN
And it returns like this:
{
"og_object": {
"id": "1084234134929324",
"description": "Marea Britanie si Irlanda. Marea Britanie spune povestea a trei tari: Anglia, Scotia si Tara Galilor, in care castelele, catedralele pub-uri sunt cu adevarat fermecatoare. In Irlanda va bucurati de peisaje naturale uluitoare, dar si de legende stravechi.",
"title": "Dal Travel - agentia devoratorilor de turism",
"type": "website",
"updated_time": "2016-01-10T12:20:56+0000",
"url": "https://www.daltravel.ro/circuit/Circuit-Anglia-Scotia-Irlanda"
},
"share": {
"comment_count": 0,
"share_count": 0
},
"id": "https://www.daltravel.ro/circuit/Circuit-Anglia-Scotia-Irlanda"
}
Both methods show 0 counts, although I shared it several times. Using the second method I also get the "updated_time": "2016-01-10T12:20:56+0000" value.
How can I get the latest information ?
Thank you !