hzlzh / Alfred-Workflows

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

Shorten URL for Google does not work #18

Open raarellano opened 8 years ago

raarellano commented 8 years ago

Shorten URL Google service seems to be broken. I have included the debugging information below.

Starting debug for 'Shorten URL'

[ERROR: alfred.workflow.action.script] Traceback (most recent call last):
  File "<string>", line 84, in <module>
  File "<string>", line 27, in getLink
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 475, in error
    return self._call_chain(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden
lightheaded commented 7 years ago

It's because you need an API key for it to work. You can get goo.gl shortener working by obtaining an API key from google (https://developers.google.com/url-shortener/v1/getting_started#APIKey) and modifying "short" script filter in Alfred Workflow by double clicking it and adding the api_url for the 0: entry to the line. So

0 : {'api_url':'https://www.googleapis.com/urlshortener/v1/url','title':'goo.gl','des':'http://goo.gl/'},

becomes

0 : {'api_url':'https://www.googleapis.com/urlshortener/v1/url?key=YOUR_API_KEY_HERE','title':'goo.gl','des':'http://goo.gl/'},
raarellano commented 7 years ago

Thanks @Lightheaded, that worked. @stephenmckinney, @hzlzh I think this might be difficult for any non technical person to solve. If this can't be solved at the very least some instructions in the read me would help. Let me know if I can help and put in pull request for this.

LordZardeck commented 6 years ago

Couldn't you just use alfred workflow environment variables for this?

Gex2501 commented 6 years ago

Looks like Google is getting rid of their url shortening service. Should probably remove this from the workflow. Kinda sad really...

sfdye commented 5 years ago

Still not working