めめめ

たまに書くメモです

PythonでPush7のAPI叩く

追記(4月8日): 開けないURLがあったの1.0.1のアプデで大丈夫になった。

Push7

本来の目的と違うけど、ちょっと情報量の多いyoall的な使い方も。

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

import json
import urllib2

app_no = "APPNO"
api_key = "APIKEY"
url_icon = "アイコン画像のURL"
url_push7 = "https://api.push7.jp/api/v1/%s/send" % app_no

message = {
    "title": "タイトル",
    "body": "内容",
    "icon": url_icon,
    "url": "URL",
    "apikey": api_key
}
req = urllib2.Request(url_push7)
req.add_header("Content-Type", "application/json")
res = urllib2.urlopen(req, json.dumps(message))

自分用の通知はPushbullet使うといいよ。