hzlzh / Alfred-Workflows

Make your Alfred more powerful. (include Workflows, Extensions and Themes)
http://AlfredWorkflow.com/
1.04k stars 96 forks source link

Could you integrate tiny.cc to Shorten URL workflow? #7

Closed wxn0000 closed 10 years ago

wxn0000 commented 10 years ago

I love this workflow! I don't know if this is the right place for feature request, but it would be nice to have tiny.cc integration as well.

Thanks!!

hzlzh commented 10 years ago

@wxn0000 ok I'll look into the API of tiny.cc

wxn0000 commented 10 years ago

@hzlzh

Hi, thanks for the reply! I actually tried it myself based on your code, and it worked so far.

I added this line to the 2nd block script filter in the workflow:

{'api_url':'http://tiny.cc/?c=rest_api&m=shorten&version=2.0.3&format=json&login=[LOGIN]&apiKey=[API_KEY]&longUrl=','title':'tiny.cc','des':'http://tiny.cc/'}

and these lines to the 3rd block python script:

elif type == 'tiny.cc':
    result = json.loads(data)
    if(result["errorCode"] == '0'):
        output = result["results"]["short_url"]
    else:
        output = result["errorMessage"]

That's it! I hope I'm doing it right.

wxn0000 commented 10 years ago

And I used this as the favicon: tiny cc

hzlzh commented 10 years ago

@wxn0000 Cool~ that's great, LOGIN and APP key is needed using tiny.cc, so users can DIY themselves.