OpenSocial Templates + YQL
Here’s a simple example showing how you can use OpenSocial Templates to easily make YQL queries:
Here’s a simple example showing how you can use OpenSocial Templates to easily make YQL queries:
Some books I liked this year:
Music
| Site | Image | Result | Savings | %Savings |
| Gmail | ![]() |
8.74 KB | 2.65 KB | 23.29% |
| CO2Stats | 3.28 KB | 5.29 KB | 61.73% | |
![]() |
5.78 KB | 733 bytes | 11.01% | |
| Techcrunch | 1.60 KB | 1.45 KB | 47.5% | |
| Yahoo! News | 1.26 KB | 43 bytes | 3.23% | |
| 2.60 KB | 46 bytes | 1.7% | ||
| CNN | ![]() |
6.37 KB | 1.18 KB | 15% |
Go buy the new Radiohead song “Harry Patch (in memory of)” here: http://download.waste.uk.com/Store/did.html
The man with two brains! http://www.wimp.com/twobrained/
Planet Earth Time Lapse + The Album Leaf (The outer banks): http://bit.ly/zf0VC
My favorite in the authors@google series – “interactions between faith and science” http://bit.ly/IOUTt
Here is a YQL open data table that allows developers to use SQL-like
SELECT syntax on top of the OpenSocial REST people API.
Note: This open data table only covers the people API and needs some
more work to be useful for developers. Also, it requires the HTTPS
protocol since private keys are being transmitted.
Example query: http://tinyurl.com/qnfnzn (Uses the guid, ck, and cks
from the sample code in the opensocial php client)
Source code for the opensocial.people open data table:
<?xml version="1.0" encoding="UTF-8" ?> <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd" https="true"> <meta> <author>Chirag Shah</author> </meta> <bindings> <select itemPath="" produces="XML"> <urls> <url>http://sandbox.orkut.com/social/rest/people/</url> </urls> <inputs> <key id='method' type='xs:string' paramType='variable' const="true" default="opensocial.people" /> <key id='ck' type='xs:string' paramType='variable' required="true" /> <key id='cks' type='xs:string' paramType='variable' required="true" /> <key id='guid' type='xs:string' paramType='variable' required="true" /> <key id='selector' type='xs:string' paramType='variable' required="true" /> <key id='count' type='xs:string' paramType='variable' required="true" default="20" /> <key id='container' type='xs:string' paramType='variable' required="true" /> </inputs> <execute><![CDATA[ // Include the signing library y.include("http://oauth.googlecode.com/svn/code/javascript/oauth.js"); y.include("http://oauth.googlecode.com/svn/code/javascript/sha1.js"); var base; if(container == 'orkut') base = 'http://sandbox.orkut.com/social/rest/people/'; else if(container == 'friendconnect') base = 'http://www.google.com/friendconnect/api/people/'; else base = ''; var requestUrl = base + guid + '/@' + selector + '/'; var accessor = {consumerSecret: cks}; var message = { method: "GET", action: requestUrl, parameters: [ ['oauth_signature_method', 'HMAC-SHA1'], ['oauth_consumer_key', ck], ['oauth_version', '1.0'], ['xoauth_requestor_id', guid], ['format', 'json'] ] }; OAuth.setTimestampAndNonce(message); OAuth.setParameter(message, "oauth_timestamp", OAuth.timestamp()); OAuth.SignatureMethod.sign(message, accessor); var finalRequestUrl = OAuth.addToURL(message.action, message.parameters); response.object = y.rest(finalRequestUrl).get().response; ]]></execute> </select> </bindings> </table>
Simple script to post a list of links to delicious, along with the related tags for that link.
Yes, I also wish delicious.com supported OAuth
import os, urllib, urllib2, time, sys from BeautifulSoup import BeautifulSoup from BeautifulSoup import BeautifulStoneSoup user = 'insert_the_user_name' pasw = 'insert_the_password' password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm() password_manager.add_password(None, 'https://api.del.icio.us/', user, pasw) auth_handler = urllib2.HTTPBasicAuthHandler(password_manager) opener = urllib2.build_opener(auth_handler) urllib2.install_opener(opener) for url in open('./all_links.txt'): try: title = urllib.quote(BeautifulSoup(urllib.urlopen(url)).title.string) url = urllib.quote(url) tags = "hn_links" for suggestion in BeautifulSoup( urllib2.urlopen("https://api.del.icio.us/v1/posts/suggest?url=%s" % url).read()).findAll('popular'): tags = tags + "+" + suggestion.string print urllib2.urlopen("https://api.del.icio.us/v1/posts/add?url=%s&tags=%s&description=%s" % (url, tags, title)).read() time.sleep(9) except: print sys.exc_info()