def share_fb(request, **kwargs): if request.method == 'POST': photo_id = request.POST["photo_id"] comment = request.POST["comment"] if not re.match('^[0-9]+$', photo_id): raise Exception('Invalid input') photo = Photo.objects.select_related('album', 'album__owner').get(id=photo_id) if not photo.can_view_photo(request.user): raise Exception('unauthorized') from account.graphapi import GraphAPI fb_user = request.user.get_profile().get_facebook_user() graph = GraphAPI(fb_user.access_token) photo.original_image.open() pd = photo.original_image.file graph.put_photo(pd.file) response_dict = {"success": True, "message": "Done"} return HttpResponse(simplejson.dumps(response_dict, cls=PDEncoder), mimetype='application/javascript')
def share_fb(request, **kwargs): if request.method == 'POST': photo_id = request.POST["photo_id"]; comment = request.POST["comment"]; if not re.match('^[0-9]+$',photo_id): raise Exception('Invalid input') photo = Photo.objects.select_related('album','album__owner').get(id=photo_id) if not photo.can_view_photo(request.user): raise Exception('unauthorized') from account.graphapi import GraphAPI fb_user = request.user.get_profile().get_facebook_user() graph=GraphAPI(fb_user.access_token) photo.original_image.open() pd = photo.original_image.file graph.put_photo(pd.file) response_dict = { "success":True, "message": "Done" } return HttpResponse(simplejson.dumps(response_dict, cls=PDEncoder), mimetype='application/javascript')