Created
June 11, 2012 21:26
-
-
Save yurivictor/2912840 to your computer and use it in GitHub Desktop.
Get favorites/likes from various APIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
def get_twitter_favorites(): | |
# SET UP VARIABLES | |
SCREEN_NAME = 'yurivictor' # Please change this | |
BASE_URL = "https://api.twitter.com/1/favorites.json?screen_name=" | |
URL = BASE_URL + SCREEN_NAME | |
# GRAB LATEST FAVORITES | |
# FOR USER FROM TWITTER | |
# https://dev.twitter.com/docs/api/1/get/favorites | |
response = requests.get(URL) | |
content = response.content | |
json_result = json.loads(content) | |
return json_result | |
def get_youtube_favorites(): | |
# SET UP VARIABLES | |
# YOUTUBE JSON SUPPORT: | |
# https://developers.google.com/youtube/2.0/developers_guide_json | |
SCREEN_NAME = 'deuclion' # Please change this | |
URL = "https://gdata.youtube.com/feeds/api/users/%s/favorites?alt=json" % SCREEN_NAME | |
# GRAB LATEST FAVORITES | |
# FOR USER FROM YOUTUBE | |
# https://developers.google.com/youtube/2.0/developers_guide_protocol_favorites#Retrieving_favorite_videos | |
response = requests.get(URL) | |
content = response.content | |
json_result = json.loads(content) | |
return json_result | |
def get_instagram_likes(): | |
# SET UP VARIABLES | |
# GETTING AN ACCESS TOKEN: | |
# http://instagram.com/developer/authentication/ | |
ACCESS_TOKEN = '632495.f59def8.8b48cda0981046519c73fa8513c573be' # Please change this | |
BASE_URL = 'https://api.instagram.com/v1/users/self/media/liked?access_token=' | |
URL = BASE_URL + ACCESS_TOKEN | |
# GRAB LATEST LIKES | |
# FOR USER FROM INSTAGRAM | |
# http://instagram.com/developer/endpoints/users/ | |
response = requests.get(URL) | |
content = response.content | |
json_result = json.loads(content) | |
return json_result | |
get_twitter_favorites() | |
get_youtube_favorites() | |
get_instagram_likes() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment