def test(request): context = {} authentication = Authentication() context['authorization_url'] = authentication.get_authorization_url() return render(request, 'instaPhotoCollector/test.html', context)
def test_2(request): context = {} error = request.GET.get('error', '') error_reason = request.GET.get('error_reason', '') error_description = request.GET.get('error_description', '') if error == "access_denied": context['msg'] = "You denied the authorization to our application." authentication = Authentication() context['authorization_url'] = authentication.get_authorization_url() return render(request, 'instaPhotoCollector/test.html', context) code = request.GET.get('code', '') oauth_token = access_token_curl_request(code) #""" access_token = oauth_token["access_token"] """ user_username = oauth_token['user']['username'] user_bio = oauth_token['user']['bio'] user_website = oauth_token['user']['website'] user_profile_picture = oauth_token['user']['profile_picture'] user_full_name = oauth_token['user']['full_name'] user_id = oauth_token['user']['id'] """ """ print access_token print user_username print user_bio print user_website print user_profile_picture print user_full_name print user_id #""" # result = get_users_self(access_token) """ user_counts = result['counts'] user_media = user_counts['media'] user_followed_by = user_counts['followed_by'] user_follows = user_counts['follows'] #""" """ print user_media print user_followed_by print user_follows #""" # results = get_users_self_media_recent(access_token) """ for image_object in results: print # print image_object user_has_liked = image_object['user_has_liked'] attribution = image_object['attribution'] tags = image_object['tags'] user_object = image_object['user'] comments_count = image_object['comments']['count'] filter = image_object['filter'] images = image_object['images'] # 320 x 320 low_resolution_url = images['low_resolution']['url'] # 150 x 150 thumbnail_url = images['thumbnail']['url'] # 640 x 640 standard_resolution_url = images['standard_resolution']['url'] link = image_object['link'] location = image_object['location'] created_time = image_object['created_time'] users_in_photo = image_object['users_in_photo'] caption = image_object['caption'] type = image_object['type'] id = image_object['id'] likes_count = image_object['likes']['count'] #""" """ print user_has_liked print attribution for tag in tags: print tag print user_object print comments_count print filter # print images print low_resolution_url print thumbnail_url print standard_resolution_url print link print location print created_time print users_in_photo print caption print type print id print likes_count #""" context['msg'] = "Access token get." return render(request, 'instaPhotoCollector/test_authorized.html', context)