Facebook calling Google App Engine code using GET instead of POST - python

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.

Related

How to get file from dropbox and upload on my server by using python

I am working on application where I am giving a functionality to user where they can signin from dropbox by using my application but when I am trying to get the file from Dropbox I am unable to do it. When user choose the desired file from dropbox and click on choose and then nothing happen. Can anyone please help out either is it possible to do it or not? If yes, how can we do it? I am at beginner level. Please help me out and explain the whole process to do it in detail.
Are you using public Dropbox files?
Then you just need to fetch the item by URL and download it. If this happens in a browser tool, you'll need JavaScript and not Python to download it.
Or you leave out JS and just use Python to render an HTML page where a button is for a Dropbox file and clicking the button triggers a download of the file. That is a generic HTML task you can search for.
If you need access to sign in Dropbox and view private files, consider using a Python library built around Dropbox.
See the Python Dropbox guide. Are you using a library like that? Please share as your question was vague.
https://www.dropbox.com/developers/documentation/python#
Also please share an explanation of what your logic is or a small code snippet. I can't see what you are doing yet so I don't know where you are missing something or making a mistake.
From the screenshot, I see you're using the Dropbox Chooser. That's a pre-built way to let your end-users select files from their Dropbox accounts and give them to your app.
Make sure you implement the success and cancel callback methods as documented there for the Chooser.
In the success callback, you'll get the information for the selected file(s). That occurs in JavaScript in the browser though, so if you need that on your server, you'll need to write some JavaScript to send that up to your server, e.g., via an AJAX call or a form or whatever means you use in your app.

Setting Django test cookie on every page

I am not a Django nor a Python programmer (I do know Perl, PHP, and Javascript pretty well though). I was given a Django site to work on and I understand the templating really well, I just never touch any actual Python code. My client wants a log-in on every page of the site, which is easy to do… but often when a user logs in, they get the error message "Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in." I guess that's because a test cookie is set when you go to the Django log-in page, and then when you log in, it checks for it. If you're not logging in from the log-in page/don't have the cookie set, you get the error. I tried a hack to load the login page in the background via AJAX to set the cookie and that for some reason only works about 50% of the time. Are there any Django/Python experts out there who can tell me step-by-step what a non-hack way would be to prevent this error from coming up?
Check this question for how to use Django to set persistent cookies.
Also check this question for how to get cookies.
I think the solution you need is the combination of both; create a test cookie under any name, set it, and then check to see if it exists prior to generating your view.

GAE Proxy "405 Method Not Allowed" when signing into websites

First of all, I am a noob when it comes to coding and things like that, so forgive me if any of this sounds stupid. Anyway, using Youtube and Google I managed to get my own Google App Engine Proxy Server up and running. The problem is, it won't let me sign into websites (e.g. Facebook, Twitter, etc.) while using the proxy. I enter the url into the url bar on my website/server whatever you want to call it, and it takes me there without any problems. For example, if I enter Facebook.com into the bar, it takes me to Facebook.com just fine, but when I try signing in to Facebook with my account information, the following message appears:
405 Method Not Allowed
The method POST is not allowed for this resource.
No matter what website it is, whenever I try signing in to the website with my account, I get this error. Like I said before, my knowledge with coding is limited, but I somewhat know what I'm doing. I am using Python for the coding.
The second problem I have is that whenever I try to play a flash game it doesn't load correctly, no matter what website it is. Any help?

Use Facebook Graph API with Django

I am doing a test project that uses Facebook Graph API to retrieve data from an events page. I need to use the following url: https://graph.facebook.com/OffTheGridSF/events and do a HTTP GET from my web app. I created a facebook app (for testing) and have the APP_ID, APP_SECRET. I was wondering which library (if any) should I use. I have looked at django-facebook and pyfb. I am not sure how the authentication process works. I don't need a login page for my website. I only need the JSON containing the list of events. Any help as to how I should proceed will be highly appreciated. I just started playing around with Django a few hours ago so nothing is trivial.
You can try using python requests library directly with the URL you want to GET. Checkout requests-oathlib

How to submit data of a flash form? [python]

I would like to know if it is possible to submit a flash form from python and, if it is, how?
I have done form submitting from python before, but the forms were HTML not flash. I really have no idea on how to do this. In my research about this I kept getting 'Ming'. However, Ming is only to create .swf files and that's not what I intend to do.
Any help on this is greatly appreciated.
You can set the url attribute (I think it's url, please correct me if I'm wrong) on a Flash form control to a Python script - then it will pass it through HTTP POST like any normal HTML form.
You've got nothing to be afraid of, it uses the same protocol to communicate, it's just a different submission process.
For your flash app, there's no difference if the backend is python, php or anything, so you can follow a normal "php + flash contact form" guide and then build the backend using django or any other python web framework, receive the information from the http request (GET or POST, probably the last one) and do whatever you wanted to do with them.
Notice the response from python to flash works the same as with php, it's just http content, so you can use XML or even better, JSON.

Categories