[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

マジすげぇ!! iPhone に何でも通知


http://im.kayac.com/
これを使って

iPhone アプリ
im.kayac.com: Receive your notification at iPhone
に通知出来まする

とりあえずコード

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import hashlib
import urllib2, urllib

class IMKayac:

    def __init__(self,id,password=None,sig=None):
        self.id = id
        self.password = password
        self.sig = sig

    def notify(self,msg):
        if isinstance(msg, unicode): msg = msg.encode('utf-8')
        path = 'http://im.kayac.com/api/post/%s' % self.id
        params = {
            'message':msg,
            }
        if self.password:
            params['password'] = self.password
        if self.sig:
            params['sig'] = hashlib.sha1(msg+self.sig).hexdigest()
        
        print self.getOpener().open(path, urllib.urlencode(params))

    def getOpener(self):
        opener = urllib2.build_opener()
        opener.addheaders = [
            ('User-agent',
             'TwitterCloneClient(http://d.hatena.ne.jp/jYoshiori/)'),
                             ]
        return opener
        
if __name__ == '__main__':
    from pit import Pit
    im_kayac_config = Pit.get('im.kayac.com',{'require' : {
        'id' : 'Your im.kayac.com name',
        'password' : 'Your im.kayac.com password'
        }})

    im = IMKayac(im_kayac_config['id'],
                 im_kayac_config['password'])
    im.notify(u'typester++')

これで本当になんでも通知出来ますね!!!
hudson のプラグインとか作ろうかなぁ♪

typester++

IMG_0354