Created
July 12, 2009 02:18
-
-
Save batok/145488 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import json | |
import wx | |
login = "your_bitly_login_name" | |
apikey = "your api key" | |
l_url= "http://www.google.com" # just a default url, can be anyone | |
app = wx.PySimpleApp() | |
app.MainLoop() | |
l_url = wx.GetTextFromUser( message = "Please Type URL", caption ="bit.ly shorten", default_value = l_url) | |
value = urllib.urlopen("http://api.bit.ly/shorten?version=2.0.1&longUrl=%s&login=%s&apiKey=%s" % ( l_url, login, apikey)).read() | |
d = json.loads(value) | |
bitly_url = str( d.get("results").get(l_url).get("shortUrl")) | |
txt = wx.TextDataObject( bitly_url ) | |
if wx.TheClipboard.Open(): | |
wx.TheClipboard.SetData( txt ) | |
wx.TheClipboard.Close() | |
wx.MessageBox("%s is in clipboard" % bitly_url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment