I am trying to get info for every user who liked a post within a given timeframe. As such, I am using facepy in oder to get the data from the facebook api. Now I need to now how I can paginate the data I receive from the api, however i cant get it to work. I've been looking for different solutions that use the facebook sdk, however i cant get them them to work either.
My code so far looks as follows:
graph_data = graph.get('me/posts?fields=likes',since=sTime, until=uTime)
for info in graph_data['data']:
while True:
try:
for comment in info['likes']['data']:
print comment
info =requests.get(info['likes']['paging']['next']).json()
except KeyError:
break
I receive as output the people who liked each post within the timeframe, however I realize that this list does not include all the users who liked (as i can see more on facebook)
Thank you very much!
Related
I am working on a project that scrapes multiple YouTube channels display name, creation date, subscriber count, and view count. I need help creating this project because I can't seem to find anything about it. I have a YouTube API Key and I just can't seem to find anything about this.
It's a little hard to work with the sample code that the YouTube api shows. Use the curl section. Then send a request to the link that shows and use the information. for example send http request to this:
https://www.googleapis.com/youtube/v3/channels?part=statistics&id=[Channel ID]&key=[Your API]
and this address give you JSON file and you can get what you want!.
for example you can see subscribe count from channel list section in youtube api document. like this image.
you can find other things with this way!. good luck :)
also you can use this.
i'm making sample for you.
def subscribeCount(channel_id):
API = f"https://youtube.googleapis.com/youtube/v3/channels?part=statistics&id={channel_id}&key=[Enter Your Api Key]"
json_data = requests.get(API).json()
subscribeCount = json_data['items'][0]['statistics']['subscriberCount']
return subscribeCount
this sample need channel id(Like all other sections xD). and api key you Which you got from the google developer console.It then shows you the number of subscriptions to a channel. The rest of the sections work the same way.
Read the following article for more information.
How to Use the Python Requests Module With REST APIs
Below is the code which we used to extract the userinfo.
def getMediaLikes( params ) :
""" Get insights for a users account
API Endpoint:
https://graph.facebook.com/{object-id}?fields=likes.summary(true)&access_token={access-token}
Returns:
object: data from the endpoint
"""
endpointParams = dict() # parameter to send to the endpoint
endpointParams['fields'] = 'likes.summary(true)' # period
endpointParams['access_token'] = params['access_token'] # access token
url = params['graph_domain'] + object_id # endpoint url
return makeApiCall( url, endpointParams, params['debug'] ) # make the api call
But the above code is giving error:
{'error': {'message': '(#100) Tried accessing nonexisting field (reactions) on node type (ShadowIGMedia)', 'type': 'OAuthException', 'code': 100, 'fbtrace_id': 'ACiWMzqRHhPHYygSK5PO4ge'}}
Can somebody help on this? Thanks
im currently working on a project with similar problems, my approach to this problem was not to use the instagram api but instead to go to instagram.com, open my requests analyzer and understand wich requests to make to get the infos i want. Maybe you can use this approach (this way of doing things is a bit harder to use than an API but you have no limits with it).
What i would do is asking for the list of users that liked the post by copying the request my browser send when i'm doing it by hand (clicking on the list of persons that liked the post), be aware that you will need to manage the cookies instagram gives you in most cases.
I think there might be a way of doing this with the API but if there isn't... you can still do this to extract the list of peoples that liked a post.
I am trying to get all the video ids from the page. I am using v10.0 Graph API to achieve this.
Here is the API URL that I am requesting.
https://graph.facebook.com/v10.0/{{page_id}}/videos?limit=1&fields=id&access_token={{access_token}}
At the first request, it is giving me a proper response. Once, I request for another page, using the page_token that I get from the first response, it is giving me an error "Please reduce the amount of data you're asking for, then retry your request"
I have checked many questioned related to this and tried to apply a limit of 1 on the query but still, the 2nd-page request is throwing the same error.
Please check the screenshot attached for more reference.
Can anybody help me with this?
Thanks in advance!!!
I'm trying to use the Vimeo API with Python, but I'm stuck trying to find video's using keywords.
What I have is this, after successfully registering with Vimeo:
import vimeo
client = vimeo.VimeoClient(
token='my_token',
key='my_key',
secret='my_secret_key'
)
about_me = client.get('/me',params={'fields':'uri,name'})
json.loads(about_me.text)
these return my user credentials. Now I want to use a similar approach to get videos using Query keywords, like on their page. But I cannot get it to work.
So, I want to have a JSON returned with movies based on keywords (like 'interstellar trailer' and not the URI or id of Vimeo).
But for some reason, I can't get the query keyword to work, and from the linked page above, I cannot figure it out how to implement it in my code.
27-02-19: UPDATE: I figured it out, and will update my solution here, soon.
The /me endpoint only returns the user object for the authenticated user.
To get and search for videos, use the /me/videos or /videos endpoint (depending on if you are searching for videos on your own account, or searching for videos from other users public on Vimeo).
I'm trying to set up the Twitter API to change a Twitter account display picture and description. After setting the API keys and telling it to do it's magic, I can get through without any errors, except after checking the Twitter account and finding none of my changes applied. I've tried various different methods by sending the most simple descriptions and pictures through the API but still got nothing. What is it I'm doing wrong? Any help is appreciated!
import twitter
twitterAPI = twitter.Api(consumer_key=twitterConsumerKey,
consumer_secret=twitterConsumerSecret,
access_token_key=twitterAccessToken,
access_token_secret=twitterAccessTokenSecret,
)
twitter.User().SetProfileImageUrl("http://website.com/image.jpg")
twitter.User().SetDescription("Hello there")
Try this:
twitterAPI.User().SetProfileImageUrl("http://website.com/image.jpg")
twitterAPI.User().SetDescription("Hello there")
You are calling the module instead of the object.
Switched over to using Tweepy, as python-twitter doesn't actually have the ability to change the description or profile image.