Esempio n. 1
0
def method_call(request, method):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET)
    if request.user.is_authenticated():
        api.token = get_token_for_user(request.user)
        auth = True
    else:
        auth = False
    data = api.get(method, auth=auth, photo_id='6110054503')
    return HttpResponse(simplejson.dumps(data))
Esempio n. 2
0
def method_call(request, method):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET)
    if request.user.is_authenticated():
        api.token = get_token_for_user(request.user)
        auth = True
    else:
        auth = False
    data = api.get(method, auth=auth, photo_id='6110054503')
    return HttpResponse(simplejson.dumps(data))
Esempio n. 3
0
def oauth_access(request):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET)
    data = api.access_token(request)
    if data:
        data = bunchify(data)
        fs, created = FlickrUser.objects.get_or_create(user=request.user)
        fs.token = data.token
        fs.nsid = data.oauth.user.nsid
        fs.username = data.oauth.user.username
        fs.full_name = data.oauth.user.fullname
        fs.perms = data.oauth.perms._content
        fs.save()
        return HttpResponseRedirect(reverse('flickr_auth'))
    raise Exception, 'Ups! No data...'
Esempio n. 4
0
def oauth_access(request):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET)
    data = api.access_token(request)
    if data:
        data = bunchify(data)
        fs, created = FlickrUser.objects.get_or_create(user=request.user)
        fs.token = data.token
        fs.nsid = data.oauth.user.nsid
        fs.username = data.oauth.user.username
        fs.full_name = data.oauth.user.fullname
        fs.perms = data.oauth.perms._content
        fs.save()
        return HttpResponseRedirect(reverse('flickr_auth'))
    raise Exception, 'Ups! No data...'
Esempio n. 5
0
def oauth(request):
    token = get_token_for_user(request.user)
    if not token:
        api = FlickrApi(FLICKR_KEY, FLICKR_SECRET)
        url = api.auth_url(request, perms=PERMS, callback=request.build_absolute_uri(reverse('flickr_complete')))
        return HttpResponseRedirect(url)
    else:
        api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token, fallback=False)
        try:
            data = api.get('flickr.test.login')
        except:  # # FlickrUnauthorizedCall:
            fs = FlickrUser.objects.get(user=request.user)
            fs.token = None
            fs.perms = None
            fs.save()
            return HttpResponseRedirect(reverse('flickr_auth'))
    return render_to_response("flickr/auth_ok.html", {'token': token, }, context_instance=RequestContext(request))
Esempio n. 6
0
 def __init__(self):
     super(FlickrCommand, self).__init__()
     self.FLICKR_KEY = getattr(settings, 'FLICKR_KEY', None)
     if not self.FLICKR_KEY:
         raise CommandError, 'No FLICKR_KEY in settings. %s' % self.help_text
     self.FLICKR_SECRET = getattr(settings, 'FLICKR_SECRET', None)
     if not self.FLICKR_SECRET:
         raise CommandError, 'No FLICKR_SECRET in settings. %s' % self.help_text
     self.api = FlickrApi(self.FLICKR_KEY, self.FLICKR_SECRET)
Esempio n. 7
0
def get_photo_details_jsons(photo_id, token):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token)
    info = api.get(method='photos.getInfo', photo_id=photo_id)
    time.sleep(1)
    sizes = api.get(method='photos.getSizes', photo_id=photo_id)
    time.sleep(1)
    exif = api.get(method='photos.getExif', photo_id=photo_id)
    time.sleep(1)
    geo = api.get(method='photos.geo.getLocation', photo_id=photo_id)
    return info, sizes, exif, geo
Esempio n. 8
0
def oauth(request):
    token = get_token_for_user(request.user)
    if not token:
        api = FlickrApi(FLICKR_KEY, FLICKR_SECRET)
        url = api.auth_url(request,
                           perms=PERMS,
                           callback=request.build_absolute_uri(
                               reverse('flickr_complete')))
        return HttpResponseRedirect(url)
    else:
        api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token, fallback=False)
        try:
            data = api.get('flickr.test.login')
        except:  # # FlickrUnauthorizedCall:
            fs = FlickrUser.objects.get(user=request.user)
            fs.token = None
            fs.perms = None
            fs.save()
            return HttpResponseRedirect(reverse('flickr_auth'))
    return render_to_response("flickr/auth_ok.html", {
        'token': token,
    },
                              context_instance=RequestContext(request))
Esempio n. 9
0
def get_photo_exif_json(photo_id, token):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token)
    exif = api.get(method='photos.getExif', photo_id=photo_id)
    return exif
Esempio n. 10
0
def get_collection_info_json(collection_id, token):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token)
    return bunchify(api.get(method='collections.getInfo', collection_id=collection_id))
Esempio n. 11
0
def get_collections_tree_json(nsid, token):
    """tree for user or tree for collection"""
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token)
    return bunchify(api.get(method='collections.getTree', user_id=nsid))
Esempio n. 12
0
def get_user_json(nsid, token):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token)
    return bunchify(api.get(method='flickr.people.getInfo', user_id=nsid))
Esempio n. 13
0
def get_photoset_photos_json(photoset_id, token):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token)
    return bunchify(api.get(method='flickr.photosets.getPhotos', photoset_id=photoset_id))
Esempio n. 14
0
def get_photosets_json(nsid, token):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token)
    return bunchify(api.get(method='flickr.photosets.getList', user_id=nsid, page=1, per_page=500))
Esempio n. 15
0
def get_photo_geo_json(photo_id, token):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token)
    geo = api.get(method='photos.geo.getLocation', photo_id=photo_id)
    return geo
Esempio n. 16
0
def get_photo_sizes_json(photo_id, token):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token)
    sizes = api.get(method='photos.getSizes', photo_id=photo_id)
    return sizes
Esempio n. 17
0
def get_photo_info_json(photo_id, token):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token)
    info = api.get(method='photos.getInfo', photo_id=photo_id)
    return info
Esempio n. 18
0
def get_photos_json(nsid, token, page=1, per_page=500, min_upload_date=None, extras=None):
    api = FlickrApi(FLICKR_KEY, FLICKR_SECRET, token)
    return bunchify(api.get(method='people.getPhotos', user_id=nsid, page=page, per_page=per_page, min_upload_date=min_upload_date, extras=extras))