2016-04-29 9 views
6

enter image description hereCome posso ottenere il conteggio Facebook Graph API sintesi reazione separatamente

Come posso ottenere il conteggio Facebook Graph sintesi reazione api separatamente, Quando provo nel grafico Explorer, es:? 614689638666135_785960901539007/campi = reactions.summary (vero) Ricevo totale e viewer_reaction, ma non abbastanza, qualcuno ti può aiutare?

+0

I'v provato questo e ha lavorato per me: http://stackoverflow.com/questions/36906590/getting-facebook-post-all-reactions-count-in-single-graph-api-request –

+0

@ JoãoCabral, anche io, la stessa soluzione –

risposta

16

È necessario chiedere espressamente per ciascuna reazione, tuttavia come indicato nei commenti, è possibile sfruttare l'alias di campo.

>>> fb_get_url = 'https://graph.facebook.com/v2.6/%s' % result['id'] 
>>> query_pieces ['reactions.type(LIKE).limit(0).summary(true).as(like)','reactions.type(LOVE).limit(0).summary(true).as(love)','reactions.type(WOW).limit(0).summary(true).as(wow)','reactions.type(HAHA).limit(0).summary(true).as(haha)','reactions.type(SAD).limit(0).summary(true).as(sad)','reactions.type(ANGRY).limit(0).summary(true).as(angry)', 'reactions.type(THANKFUL).limit(0).summary(true).as(thankful)'] 
>>> full_query = ",".join(query_pieces) 
>>> r = requests.request("GET", fb_get_url, params={'access_token' : my_creds['access_token'], 'fields' : full_query}) 
>>> print(dumps(r.json(), indent=2)) 
{ 
    "love": { 
    "data": [], 
    "summary": { 
     "total_count": 0, 
     "viewer_reaction": "LIKE" 
    } 
    }, 
    "like": { 
    "data": [], 
    "summary": { 
     "total_count": 1, 
     "viewer_reaction": "LIKE" 
    } 
    }, 
    "wow": { 
    "data": [], 
    "summary": { 
     "total_count": 1, 
     "viewer_reaction": "LIKE" 
    } 
    }, 
    "haha": { 
    "data": [], 
    "summary": { 
     "total_count": 0, 
     "viewer_reaction": "LIKE" 
    } 
    }, 
    "sad": { 
    "data": [], 
    "summary": { 
     "total_count": 0, 
     "viewer_reaction": "LIKE" 
    } 
    }, 
    "thankful": { 
    "data": [], 
    "summary": { 
     "total_count": 0, 
     "viewer_reaction": "LIKE" 
    } 
    }, 
    "id": "10100996730306423_10101331756810623", 
    "angry": { 
    "data": [], 
    "summary": { 
     "total_count": 0, 
     "viewer_reaction": "LIKE" 
    } 
    } 
} 
>>> 
+0

grazie, è un lavoro! :) –

+0

fantastico - grazie mille - mi ha davvero aiutato! –

+1

posso sapere dove è documentato in Graph API? – cherhan