Alfred-Workflows icon indicating copy to clipboard operation
Alfred-Workflows copied to clipboard

Shorten URL for Google does not work

Open raarellano opened this issue 9 years ago • 5 comments
trafficstars

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

raarellano avatar May 11 '16 13:05 raarellano

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/'},

lightheaded avatar Nov 03 '16 13:11 lightheaded

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.

raarellano avatar Nov 03 '16 13:11 raarellano

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

LordZardeck avatar Jan 12 '18 17:01 LordZardeck

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

Gex2501 avatar Jun 06 '18 01:06 Gex2501

Still not working

sfdye avatar Oct 29 '18 07:10 sfdye