get additional info from facebook-sdk using python - python

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!!

Related

How to get account information via using API Binance in Python

I am trying to get account information by using requests library with the code below.
enter image description here
import requests
url = 'https://api.binance.com'
api_get_info = '/sapi/v1/accountSnapshot'
hmac_sha256 = 'api_key'
get_account_info = requests.get(url+api_get_info+api_get_info)
print(get_account_info.text)
I have no idea what the url should be like. Could you guys please give me some idea :)
Binance has an official GitHub repository with examples about these signatures, you can check it out over here: https://github.com/binance/binance-signature-examples/blob/master/python/spot/spot.py
See the function send_signed_request() at the bottom of that file.

Searching keywords using facebook graph API in Python

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.

LinkedIn API: get r_basicprofile using URL/vanityName

I'm new to LinkedIn API.
Is there any way to retrieve r_basicprofile using v1 API?
I'm using Python and my GET url is:
'https://api.linkedin.com/v1/people/~?url=%s&oauth2_access_token=%s&format=json' %(v_member_url,v_access_token)
I get only my profile no matter what I put in v_member_url.
https://api.linkedin.com/v1/people/%s&oauth2_access_token=%s&format=json' %(v_member_url,v_access_token)
try this
the ~ symbol stands for yourself.
this should be replaced with the personID
https://api.linkedin.com/v1/people/[PERSONID]&oauth2_access_token=[TOKEN]&format=json

Problems with importing events from Facebook

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')

Python Twitter API - Set Display Picture and Description

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.

Categories

Resources