Realtime list of viewers in a Google Drive document - python

I'm working on an app which wraps Google Docs (using GAE/Python), and I want to keep track of who is viewing these docs in real-time. I can't find any APIs for this in the Google Drive SDK.
What's a good way to do this? Naively, I might imagine repeatedly polling each document individually and parsing the returned HTML. I expect there to be ~150 docs total in the system; would this be too inefficient?

Realtime api is not for using with gdocs, only for your own custom formats. Instead see the changes api in drive but you wont be able to detect viewers only modifications https://developers.google.com/drive/manage-changes

I am not sure if this meets your requirement but there is a Realtime API available in the Drive SDK.
The catch is that it is JavaScript only. It does have Events that your web client can be notified off like CollaboratorJoinedEvent and CollaboratorLeftEvent.

Related

Search all of Google with Google Python API

I will be using python. My plan is to make a program that searches a bunch of things, and sees how many search results google has for it. But I can only figure out how to get custom search engine to kind of work.
In python, how do I use the Google API to do a simple search using Google's main search engine? As I understand, the answer to this has changed within in the last few years as google has made a push to the google app engine.
Recently I was also looking for Google Search API and was misguided by a lot of outdated information. Here is what I found on Google Developers website: https://developers.google.com/api-client-library/python/apis/customsearch/v1
According to the docs your function will be something like
from googleapiclient.discovery import build
def google_results_count(query):
service = build("customsearch", "v1",
developerKey="[put your API key here]")
result = service.cse().list(
q=query,
cx='[put your CSE key here']
).execute()
return result["searchInformation"]["totalResults"]
print google_results_count('Python is awesome')
Unfortunately, using CSE API will give you different result count from the one you get using web search. In the example above I got 2 680 000 in Python and approx. 21 000 000 for the same query on Google.com
Here is an explanation why: https://support.google.com/customsearch/answer/70392?hl=en
Getting the API and CSE keys and all the limitations of CSE is a whole different story, I highly recommend you looking at this answer: https://stackoverflow.com/a/11206266/1704272 and the next one below for the alternatives.
Another approach is to parse the HTML response from Google.com which will give you the most complete results but it is not very reliable because Google changes the HTML markup. And more important this is against their TOS, more to read here: Is it ok to scrape data from Google results?
My conclusion.
You have three options:
Use Google CSE API (free). Use this, if you need to stay legal and you are sure you won't exceed the limit. Can not be used in public application.
Use paid API (Google or any other, less expensive). It is legal to use this for any public application but be ready to pay for that.
Scrape Google web page. This will give you the best results but I would use this option only for private needs.

How do I send myself a message on Facebook using python?

It appears pyfacebook and simplefacebook are deprecated. So is the facebook e-mail service. What is the current way of accomplishing this?
https://developers.facebook.com/products/messenger/
There appears to be links to build apps integrating messenger support here.
You can try to utilize the APIs there, since several apps seem integrated using it, I assume it is unlikely to change drastically anytime soon.
Here is a link I found which demonstrates the API for how to send messages using facebook's send API https://developers.facebook.com/docs/sharing/reference/send-dialog The tutorial is for Javascript but you might be able to adapt it to work for Python as well.
Here's the build for an app called Facebook Autoresponder, you might be able to reverse engineer their process from looking at it : http://sourceforge.net/projects/facebook-autoresponder/files/?source=navbar

embedding videos loaded on box

So basically we would like to integrate our platform with box.net, in particular to be able to stream videos uploaded there, since we can't unfortunately use youtube/vimeo (which support noembed).
I had a look in the doc and:
it seems that for videos the preview is only working for flv and swf.
However I tried with my personal account and one swf embedded with their embedding link didn't preview anyway.
I would like to use the API to upload videos directly from the client, but what happens if the user is not actually authenticated to box.net and the video is private (which is our requirement).
If embedding videos with box is just not going to work we can look at other alternatives, but unfortunately from the list of supported sites http://noembed.com/
it doesn't that we could use any of the services..
For the second point, you can just do all the authentication for your site via box.net. They provide authentication as part of their api: http://developers.box.com/oauth/.
When a user logs into your site, authenticate them with box.net using python requests, and a custom authentication backend, django docs here, example on stack overflow here: Django Remote Authentication without redirecting.

Log-in to a website using Google, Facebook or Twitter accounts with Python

I am making a web application that will monitor the amount of members and discussions in each one of the groups listed here (http://www.codecademy.com/groups#web) and display that information in nice graphs.
However, as you have already seen, it looks like I need to create an account and login with it.
Having in mind that my project is using Python for the server side, how do I do it? Which API is easier? (Google, FB or twitter?)
I would really love if you could also provide some examples because I am really new at this (and at Python too).
The official wrapper around the Twitter API for Python is this one. I used it and it's very easy. You should first read this page and also register an application to get OAuth keys.
Example:
import twitter
# Remember to put these values
api = twitter.Api(consumer_key="",
consumer_secret="",
access_token_key="",
access_token_secret="")
# Get your timeline
print api.GetHomeTimeline()
Hope it helps.

You Tube API Calls

I have cut and pasted a python code sample from Google API to access You Tube video viewing data of my companies videos. The application will be scheduled and get usage data then write to a database on the server ( CENTOS ). I have tried both Simple API and installed application types. Is there a solid samle type that you know of or anyone else having issues with the API calls? My latest error is that the JSON file is not organized correctly ( which I got from the API page unaltered ).
Most google api code snippet require the user to input their personal API KEY. Please be sure you have appropriately updated the code snippet to use your api key.

Categories