I recently started working on sentiment analysis for which I need data from Facebook/Instagram post/comment/replies. I plan to search a keyword or tag and would get data from the results. I looked up facebook graph api and some blogs and I found code of 2016 which did exactly that but it isn't working.
import urllib3
import facebook
import requests
token= # mytoken
graph = facebook.GraphAPI(access_token=token, version = 3.1)
events = graph.request('/search?q=Poetry&type=event&limit=10000')
This code finds information on events for any search term say “Poetry” and limiting those events number to 10000
but when I run it I get the following error:
Tell me if it possible and what I should do to fix it.
Related
I have created a twitter bot using the Tweepy API. It works great, it tweets a tweet with a photo attached to it. However, I would like to add "mentions" or "In this photo" #accounts (tags) to the attached image. This is possible on twitter. I have red the Tweepy documentation and searched online, looking for a parameter but I could not find anything. Any suggestion would appriciated!
code snippet:
api = tweepy.API(oauth)
api.update_with_media(filename='screenshot.png', status=masterStatus)
First of all, please do not use update_with_media, as this is a deprecated API. It works for now, but will get no support. The current correct route is the two-step use of media_upload, followed by update_status (you can also add image alt text using create_media_metadata in between those two steps, if you like). The Tweepy 3.9.0 documentation mentions this.
For the main part of the question - the Twitter API itself does not currently support adding people tags to images, so this is also unavailable in Tweepy. If you would like to request this feature in a future version of the Twitter API, you can do so here.
I am to import information about events from Facebook.
I've generated the token, downloaded all the needed libraries.
Here is my code (for example I wanted to download events linked to "Poetry"):
import urllib3
import facebook
import requests
token = 'xyz'
graph = facebook.GraphAPI(access_token = token, version = 2.7)
events = graph.request(‘/search?q=Poetry&type=event&limit=10000’)
Unfortunately an error occurs
How can it be fixed?
I have one more question - how is it possible to download information over some events in a particular location?
I would appreciate any hints or tips.
You need to use apostrophes to enclose a string:
graph.request('/search?q=Poetry&type=event&limit=10000')
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!
I am using python to get info data from facebook api.
I use the following code:
import facebook
import requests
token = 'mytoken'
graph = facebook.GraphAPI(token)
profile=graph.get_object("me")
but only the name and the id are returned. Thus i cannot use the command
profile["gender"]
in order to get the user's gender.
How can i fix that?
thank you!!
I am trying to pull tweets matching the given search query. I'm using the following code :
import urllib2 as urllib
import json
response = urllib.urlopen("https://search.twitter.com/search.json?q=microsoft")
pyresponse = json.load(response)
print pyresponse
This was working a few days ago, but suddenly stopped working now. With some help from google, I learned that this type of url in not supported anymore.
How do I perform this search query. What url shall I use?
Twitter is deprecating non-authenticated searches. You should look into Tweepy or another Python library that interacts with Twitter. https://github.com/tweepy/tweepy