Upload Images to Django starcross gallery from External Script - python

first time question.
I have been playing with Django and needed a photo gallery, and made a basic one, then found starcross gallery (https://github.com/Starcross/django-starcross-gallery). It works really nice and easy to put into my app, but from what I can tell its made for dragging and dropping images in, or by adding them from the django-admin page.
I need to be able to add photos from an external script. I haven't dealt with ImageField before. I was able to import the gallery.models in my api views file, and make it so I can POST and add those ok. But I have been pulling my hair out trying to get actual images to upload.
From looking around, I found I think how to do it with curl (I make my requests with curl then port it to python), and it gave me CSRF issues with a 403 Forbidden.
How can I upload an image and bind it to an album, externally with curl or Python?
Thanks

Related

Retrieving Facebook Page comments with python script

I am building a python script that is trying to stream a screen capture to my Facebook Page and to be able to retrieve all the comments from the Facebook Live stream real time so that I can do some processing in the middle of the stream.
The Facebook App was set up (in development mode) but when I tried to retrieve the comments from my live stream, I am only able to retrieve comments with their name and id ("from") that are made as the Facebook Page Admin, not comments that are made by other users. I need the user's id, user's name and their comments.
I understand that I need to get Facebook App to be live mode in order to retrieve all the comments with their details tagged to it. When I tried to get it, it tells me that I need to get the permission approved. I tried to fill in most of the stuff and try to get the two permission (manage_page for the comments and live video API for the streaming) but I was unable to because I left the platform empty.
Below is the message I got:
You do not have any platforms eligible for review. Please configure a platform on your Settings page.
The problem is when I tried to choose a platform that was shown in the list, python script does not fall in the list of platform.
Does anyone know of a solution or a different way to achieve what I need to retrieve?
Have you tried using PyLivestream?
It can be used to stream to Facebook Live using FFmpeg (to multiple services simultaneously actually, like Periscope, YouTube etc).
It adheres to the RTMPS requirement and should be an option for you if I interpret your needs correctly.
python -m pip install PyLivestream
Facebook Live
Facebook Live requires FFmpeg >= 4.2 due to mandatory RTMPS
configure your Facebook Live stream
Put stream ID from https://www.facebook.com/live/create into the file facebook.key
Run Python script for Facebook with chosen input
Check out the PyPi PyLivestream page for details.
To be able to retrieve all the comments from the Facebook Live stream
I'm not sure if this is possible using PyLivestream alone, but the Polls API can be used to represent VideoPoll objects in the Graph API, to create polls on live video broadcasts and get real-time responses from your viewers and can be created with the
POST /{live-video-id}/polls
endpoint on a LiveVideo object.
Upon creation, the API will return a VideoPoll object ID, which you can use to manipulate the poll and query for viewer interactions.
Guess you'll have to do a bit of digging to figure out the details,
but I believe this would be the right way to approach this task.
In order to get the "from" field when retrieving the comments, you need to have manage_pages permission from your Facebook App that is linked to your Facebook Page. You will need to submit an App review for your Facebook App that usually takes 1-3 days to process. If you are lucky, it will probably take about 6-8 hours.
Once it is approved, you can request the permission and get your application to go live.
Also use the Page Access token in your "access_token" field when invoking the API so that it will allow you to pull the "from" field, which contains the id and name of the user.

Telegram image scraper

Hi, I have trouble with Telegram images scraper (I don't know how to call it). It's a feature that puts an image in chat via URL.
(Screenshot below).
But when I am trying to serv static files by Django or Flask Telegram really can't scrap that image.
(Screenshot below)
Also, I've tried NGINX server but seems similar.
Did anybody know how that feature works or somebody tried to do that
on their own? Maby I should register the domain?

Hiding Image in url and right click save option using Django

Iam using Django templates. I want to view image in webpages using django templates.But i want to restrict the image whenever we right click the image and click save as option and by taking html page source.
I have tried the link which is somehow similar which i want Can I use Django to prevent direct access to an image file? In Session Middleware, if image path, i redirected it to same view from where it called,
for gated in settings.GATED_CONTENT:
if path.startswith(gated) or path.endswith(gated):
is_gated = True
return redirect(reverse('my_view'))
By doing so, image is not displaying in webpage. Can Anyone help me?
The question you linked to doesn't do what you are asking (if I understand what you're asking correctly). You want to restrict people from being able to save an image that your site has served to their local machines (which can't be done).
The question you linked is about how to restrict image access to logged in users, probably to prevent hotlinking etc.

Image Uploading Script in Python

I was trying to make an image uploading script for Postimage.org.
I tried searching for an API but it seems that there is not any available. Can anyone help me how to make this script ? I don't have any idea how to make the uploading proccess? I think that something that i should do is open the image file in read binary mode ("rb").
Anyway i am waiting for your suggestions and ideas.
Firstly you should think about what happens when you press the upload button on the website. What your script could do is mimic this functionality, because essentially all it's triggering is a POST request to the web server with the specified information in the form and the image file data. You can initiate HTTP requests (e.g. GET, POST, etc.) using a library such as Requests (http://docs.python-requests.org/en/latest/index.html).
However, as this seems to have been discussed before, I will instead point you in the right direction: Send file using POST from a Python script

Facebook calling Google App Engine code using GET instead of POST

I've been developing a Facebook app using Google App Engine in Python and the pyfacebook bindings. For weeks everything worked fine but suddenly it stopped.
At first I thought it was a code change so I rolled back the entire dev directory to a version I knew worked, but still it failed. It's possible a change I made to the application's settings caused the issue but, if so, I can't figure out what.
I've figured out that the problem is that instead of calling the post(self) method of my Main class, Facebook is calling using a GET.
Does anyone know why Facebook would use a GET method instead of a POST? It's an IFrame app.
Thanks,
The typical flow for a user when using the application begins with the user landing at some Canvas URL, like http://apps.facebook.com/runwithfriends/. At this point, Facebook will load up it's chrome, and render a tag to your application. You'll notice there isn't a src specified. Using some JavaScript and the tag, Facebook triggers a POST request to your application. This is done for security reasons, as the sensitive user data won't be sent via the HTTP Referrer header as long it's sent as POST data.
Although I'm not completely sure this was the cause, it appears I changed from an FBML app to an IFrame app. FBML mode relies on POST calls but IFrame appears to use GET. I'm inferring this answer from what I read here as well as from the observations I'm seeing and this being the only answer that makes any sense.

Categories