Using Django with the Facebook API for a polling app - django

I randomly pick two friends of the user and ask him/her to pick who is the better friend. Now all I have is the friend ID which I then have to use to create a poll and store in the database accordingly. Using the Facebook graph API, I have the ID. All I need to do now is to pass it to Django.
I'm new to this so how exactly would I do that? Pass a javascript variable to Django?

I see two options.
At client side using Javascript SDK,
Fetch the friends' profile details along with ID.
Convert them to JSON.
Do a POST request to a django url/view which stores the data in database.
In this way, you don't need to do any graph API queries further from server side. But this won't help you updating the data at realtime. Consider, if one of the friends changing his name in FB, now what is stored in your database becomes obsolete. So, you need to make sure that some thing from client side implemented to do real time update posts to server side.
At server side using any django facebook graph API apps,
Get the IDs from client side.
Use the fb graph app to fetch the details at server side.
Store them in database.
In this way, you could be able to schedule a callback for real time updates. I prefer the second approach as it's always better to burden the server rather than client. And I found this app simple and do what you need. https://pypi.python.org/pypi/django-facebook-api/0.1.10

Related

Where can I store the refresh and access token in django

I'm using django and trying to integrate it with quickbooks online through python-quickbooks package and already did so and it works fine, but the problem is I don't want to store the tokens in the request session because I'm trying to access them outside the views, to be exact I'm trying to send an invoice each time an invoice(invoice model from django) object was made I want to send one to quickbooks and I'm doing this through django signals but I can't access the session from the signals so where is the best place to store them on the server side?
thanks in advance.
You can create new Django model just for your integration and query it when you need to get tokens. Especially it can be useful if you plan to have multiple integrations, you can add relation from object (which is related to signal) to "integration object".

Single table vs Table per user

I am creating backend for a messaging application. I want it to be mostly a web app so would have to store the list of people with whom a user chats and all the messages in the server. However, I also wanted to have the ability to extend it and use the same backend for a mobile app. So I was thinking of having a separate database or table for every user and only open the connection to it when a user connects to the backend using WebSocket. However, according to this post, it seems that in most cases, it is better to have a single table and have many to one relation. So what would be the best choice in my usage? Also, how can I go about implementing that in Django?

When creating a "Restful" webservice can standard http get & http post syntax be used?

We are working in the office using Oracle APEX to create some web services. After beating our heads against the wall we finally figured out that the terms get & post when talking about RESTful services are not the same as standard HTTP.
We will need to create two types of web services;
In the first, the external application passes a few fields and the method queries a record and sends the data back to the external application.
In the second an external application builds a 30 field record that needs to be inserted by the method into the DB.
In a normal web app we would in both cases typically http post the data to to a cgi (asp, aspx, pl...) page that would parse the fields and do what needs to be done.
Since we have written the new app in APEX, and we would like to join the late 20th century, we thought we would use a web service on the provider side. The consumer will be AS3/flex/flash.
Can we still use the traditional http post and/or http get methodology of defining name=data pairs and send them to the web service?
What we have seen so far is that the data passed (at least in an APEX Restful GET) needs to be positional and not name=data pairs.
I guess the first question is where can we get some basic concepts on how to pass data using "RESTful" get & post? Something aimed at a web service dolt would be good.
Another question is if the HTTP get/post methodolgy can be used, how would it be done in Oracle APEX v5.0?
There is a lot of questions inside your post, perhaps if you narrow it down to a specific problem, you'd get better answers. I've used RESTful services with APEX 4.2, 5, 5.1 and they work just fine.
In the first, the external application passes a few fields and the method queries a record and sends the data back to the external application.
This is typical GET request. You pass the parameters (I usually pass them as part of the URL), use them in query, and return the values. You can even pass them to PL/SQL block, do whatever processing you need, then return the results.
In the second an external application builds a 30 field record that needs to be inserted by the method into the DB.
This is typcial POST request (although you still can use GET but not recommended). The format of how the data is being sent is important. I've done that using JSON format, and received as bind variable :body at APEX end. In APEX you can parse it and insert it into a table.
Few resources might help you to get going:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r50/Restful%20Services/restful_services.html#section1
This is especially helpful for POST:
https://ruepprich.wordpress.com/2016/03/22/apex-rest-post/

Survey App Django-Survey Monkey

I am creating a django application for my company, and one of the things that still needs doing is a survey.
At the moment we use SurveyMonkey, but I can't manage to send via api invitations to the surveys(personalized ones like the web page allows, so we know who answered with which answers).
Does anybody know if it's possible to do this with SurveyMonekey api, or if not, any other django app that what I need, or another way to do this?
SurveyMonkey's API is currently read-only and does not allow adding users to email collectors. And option you might consider is pairing SurveyMonkey with MailChimp. MailChimp currently has docs on how to use it with SurveyMonkey here: http://kb.mailchimp.com/article/setting-up-your-surveymonkey-mailchimp-integration/
You could also create something like the MailChimp API in your own application by adding a unique ID to links you send to your respondents by appending ?c=UNIQUEID to the end of a web link collector URI. Then, in your application, you can send any email invitation you like to potential respondents and use the unique ID to correlate users with responses.
You'll need to request the "custom_id" by adding it to the "fields" array in your request to get_respondent_list in order to that unique ID back from SurveyMonkey using the API.

Web access authentication in C++?

I'm trying to write a simple GUI application using Qt framework.
The purpose of this app is to retrieve data from my isp and parse them for presentation.
How do i authenticate my user/password with the webserver and retrieve the html page in question?
Are there any utility libs that make this task trivial?
I figure i need to interact with the server php script and simulate a form input somehow.
Am i on the right track?
You're on the right track, I suggest taking a look at curl.
That should make it alot easier.
edit: Hm, thought it did more than just file-transfer.
Otherwise here's a load more of interesting lib's
The way to authenticate depends completely on the authentication method used by the server. If it's some form to log in you need to retrieve that and send the correct data to the forms action target (usually as POST request). You could do this by constructing your request using QHttpRequestHeader and then simply sending it to the server. If you even know about the form you might even not need to retrieve the login page. If the website uses HTTP authentication you should be able using QAuthenticator.