shortenURL not working #184

Closed
opened 2013-04-19 07:53:01 -07:00 by atrociousgrmblr · 8 comments
atrociousgrmblr commented 2013-04-19 07:53:01 -07:00 (Migrated from github.com)

Hi,

shortenURL() is not working for me and return this message instead of the shorl URL:

This script is for compatibility with applications using is.gd's legacy API. It only works with requests in the old format (e.g. http://is.gd/api.php?longurl=example.com) which your request did not match. If you're having any problems with this or developing a new app please use the latest API instead, see http://is.gd/developers.php for full documentation.

Using the link given, i tried:
request = requests.get("http://is.gd/create.php", params = { 'format': 'simple', 'url': "www.google.com"})

instead of:
request = requests.get("http://is.gd/api.php", params = { 'query': "www.google.com"})

And it seems to be working as intended.

Hi, shortenURL() is not working for me and return this message instead of the shorl URL: <pre> This script is for compatibility with applications using is.gd's legacy API. It only works with requests in the old format (e.g. http://is.gd/api.php?longurl=example.com) which your request did not match. If you're having any problems with this or developing a new app please use the latest API instead, see http://is.gd/developers.php for full documentation. </pre> Using the [link](http://is.gd/developers.php) given, i tried: <code>request = requests.get("http://is.gd/create.php", params = { 'format': 'simple', 'url': "www.google.com"})</code> instead of: <code>request = requests.get("http://is.gd/api.php", params = { 'query': "www.google.com"})</code> And it seems to be working as intended.
ryanmcgrath commented 2013-04-19 07:54:35 -07:00 (Migrated from github.com)

Did their API change or something? I admit it's not something we update
often. It dates back to a time when Twitter didn't auto-shorten URLs and
we've just kept it in for legacy reasons - apparently people still use it.

We'll take care of it.

On Fri, Apr 19, 2013 at 10:53 AM, Adrien Tronche
notifications@github.comwrote:

Hi,

shortenURL() is not working for me and return this message instead of the
shorl URL:

This script is for compatibility with applications using is.gd's legacy API. It only works with requests in the old format (e.g. http://is.gd/api.php?longurl=example.com) which your request did not match. If you're having any problems with this or developing a new app please use the latest API instead, see http://is.gd/developers.php for full documentation.

Using the link http://is.gd/developers.php given, i tried:
request = requests.get("http://is.gd/create.php", params = { 'format':
'simple', 'url': "www.google.com"} http://www.google.com%22%7D)

instead of:
request = requests.get("http://is.gd/api.php", params = { 'query': "
www.google.com"} http://www.google.com%22%7D)

And it seems to be working as intended.


Reply to this email directly or view it on GitHubhttps://github.com/ryanmcgrath/twython/issues/184
.

Skype: ryanmcgrathr
Twitter: http://twitter.com/ryanmcgrath/
Web: http://venodesigns.net/
GitHub: http://github.com/ryanmcgrath/

Did their API change or something? I admit it's not something we update often. It dates back to a time when Twitter didn't auto-shorten URLs and we've just kept it in for legacy reasons - apparently people still use it. We'll take care of it. On Fri, Apr 19, 2013 at 10:53 AM, Adrien Tronche notifications@github.comwrote: > Hi, > > shortenURL() is not working for me and return this message instead of the > shorl URL: > > This script is for compatibility with applications using is.gd's legacy API. It only works with requests in the old format (e.g. http://is.gd/api.php?longurl=example.com) which your request did not match. If you're having any problems with this or developing a new app please use the latest API instead, see http://is.gd/developers.php for full documentation. > > Using the link http://is.gd/developers.php given, i tried: > request = requests.get("http://is.gd/create.php", params = { 'format': > 'simple', 'url': "www.google.com"} http://www.google.com%22%7D) > > instead of: > request = requests.get("http://is.gd/api.php", params = { 'query': " > www.google.com"} http://www.google.com%22%7D) > > And it seems to be working as intended. > > — > Reply to this email directly or view it on GitHubhttps://github.com/ryanmcgrath/twython/issues/184 > . ## Skype: ryanmcgrathr Twitter: http://twitter.com/ryanmcgrath/ Web: http://venodesigns.net/ GitHub: http://github.com/ryanmcgrath/
michaelhelmick commented 2013-04-19 07:55:20 -07:00 (Migrated from github.com)

Would you like me to just fix this for the 2.8.0 release?

Sent from my iPhone

On Apr 19, 2013, at 10:54 AM, Ryan McGrath notifications@github.com wrote:

Did their API change or something? I admit it's not something we update
often. It dates back to a time when Twitter didn't auto-shorten URLs and
we've just kept it in for legacy reasons - apparently people still use it.

We'll take care of it.

On Fri, Apr 19, 2013 at 10:53 AM, Adrien Tronche
notifications@github.comwrote:

Hi,

shortenURL() is not working for me and return this message instead of the
shorl URL:

This script is for compatibility with applications using is.gd's legacy API. It only works with requests in the old format (e.g. http://is.gd/api.php?longurl=example.com) which your request did not match. If you're having any problems with this or developing a new app please use the latest API instead, see http://is.gd/developers.php for full documentation.

Using the link http://is.gd/developers.php given, i tried:
request = requests.get("http://is.gd/create.php", params = { 'format':
'simple', 'url': "www.google.com"} http://www.google.com%22%7D)

instead of:
request = requests.get("http://is.gd/api.php", params = { 'query': "
www.google.com"} http://www.google.com%22%7D)

And it seems to be working as intended.


Reply to this email directly or view it on GitHubhttps://github.com/ryanmcgrath/twython/issues/184
.

Skype: ryanmcgrathr
Twitter: http://twitter.com/ryanmcgrath/
Web: http://venodesigns.net/
GitHub: http://github.com/ryanmcgrath/

Reply to this email directly or view it on GitHub.

Would you like me to just fix this for the 2.8.0 release? Sent from my iPhone On Apr 19, 2013, at 10:54 AM, Ryan McGrath notifications@github.com wrote: > Did their API change or something? I admit it's not something we update > often. It dates back to a time when Twitter didn't auto-shorten URLs and > we've just kept it in for legacy reasons - apparently people still use it. > > We'll take care of it. > > On Fri, Apr 19, 2013 at 10:53 AM, Adrien Tronche > notifications@github.comwrote: > > > Hi, > > > > shortenURL() is not working for me and return this message instead of the > > shorl URL: > > > > This script is for compatibility with applications using is.gd's legacy API. It only works with requests in the old format (e.g. http://is.gd/api.php?longurl=example.com) which your request did not match. If you're having any problems with this or developing a new app please use the latest API instead, see http://is.gd/developers.php for full documentation. > > > > Using the link http://is.gd/developers.php given, i tried: > > request = requests.get("http://is.gd/create.php", params = { 'format': > > 'simple', 'url': "www.google.com"} http://www.google.com%22%7D) > > > > instead of: > > request = requests.get("http://is.gd/api.php", params = { 'query': " > > www.google.com"} http://www.google.com%22%7D) > > > > And it seems to be working as intended. > > > > — > > Reply to this email directly or view it on GitHubhttps://github.com/ryanmcgrath/twython/issues/184 > > . > > ## > > Skype: ryanmcgrathr > Twitter: http://twitter.com/ryanmcgrath/ > Web: http://venodesigns.net/ > GitHub: http://github.com/ryanmcgrath/ > — > Reply to this email directly or view it on GitHub.
ryanmcgrath commented 2013-04-19 07:57:11 -07:00 (Migrated from github.com)

If you can fit it in go for it.

On Fri, Apr 19, 2013 at 10:55 AM, Mike Helmick notifications@github.comwrote:

Would you like me to just fix this for the 2.8.0 release?

Sent from my iPhone

On Apr 19, 2013, at 10:54 AM, Ryan McGrath notifications@github.com
wrote:

Did their API change or something? I admit it's not something we update
often. It dates back to a time when Twitter didn't auto-shorten URLs and
we've just kept it in for legacy reasons - apparently people still use
it.

We'll take care of it.

On Fri, Apr 19, 2013 at 10:53 AM, Adrien Tronche
notifications@github.comwrote:

Hi,

shortenURL() is not working for me and return this message instead of
the
shorl URL:

This script is for compatibility with applications using is.gd's
legacy API. It only works with requests in the old format (e.g.
http://is.gd/api.php?longurl=example.com) which your request did not
match. If you're having any problems with this or developing a new app
please use the latest API instead, see http://is.gd/developers.php for
full documentation.

Using the link http://is.gd/developers.php given, i tried:
request = requests.get("http://is.gd/create.php", params = {
'format':
'simple', 'url': "www.google.com"} http://www.google.com%22%7D)

instead of:
request = requests.get("http://is.gd/api.php", params = { 'query': "
www.google.com"} http://www.google.com%22%7D)

And it seems to be working as intended.


Reply to this email directly or view it on GitHub<
https://github.com/ryanmcgrath/twython/issues/184>
.

Skype: ryanmcgrathr
Twitter: http://twitter.com/ryanmcgrath/
Web: http://venodesigns.net/
GitHub: http://github.com/ryanmcgrath/

Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHubhttps://github.com/ryanmcgrath/twython/issues/184#issuecomment-16657751
.

Skype: ryanmcgrathr
Twitter: http://twitter.com/ryanmcgrath/
Web: http://venodesigns.net/
GitHub: http://github.com/ryanmcgrath/

If you can fit it in go for it. On Fri, Apr 19, 2013 at 10:55 AM, Mike Helmick notifications@github.comwrote: > Would you like me to just fix this for the 2.8.0 release? > > Sent from my iPhone > > On Apr 19, 2013, at 10:54 AM, Ryan McGrath notifications@github.com > wrote: > > > Did their API change or something? I admit it's not something we update > > often. It dates back to a time when Twitter didn't auto-shorten URLs and > > we've just kept it in for legacy reasons - apparently people still use > > it. > > > > We'll take care of it. > > > > On Fri, Apr 19, 2013 at 10:53 AM, Adrien Tronche > > notifications@github.comwrote: > > > > > Hi, > > > > > > shortenURL() is not working for me and return this message instead of > > > the > > > shorl URL: > > > > > > This script is for compatibility with applications using is.gd's > > > legacy API. It only works with requests in the old format (e.g. > > > http://is.gd/api.php?longurl=example.com) which your request did not > > > match. If you're having any problems with this or developing a new app > > > please use the latest API instead, see http://is.gd/developers.php for > > > full documentation. > > > > > > Using the link http://is.gd/developers.php given, i tried: > > > request = requests.get("http://is.gd/create.php", params = { > > > 'format': > > > 'simple', 'url': "www.google.com"} http://www.google.com%22%7D) > > > > > > instead of: > > > request = requests.get("http://is.gd/api.php", params = { 'query': " > > > www.google.com"} http://www.google.com%22%7D) > > > > > > And it seems to be working as intended. > > > > > > — > > > Reply to this email directly or view it on GitHub< > > > https://github.com/ryanmcgrath/twython/issues/184> > > > . > > > > ## > > > > Skype: ryanmcgrathr > > Twitter: http://twitter.com/ryanmcgrath/ > > Web: http://venodesigns.net/ > > GitHub: http://github.com/ryanmcgrath/ > > — > > Reply to this email directly or view it on GitHub. > > — > Reply to this email directly or view it on GitHubhttps://github.com/ryanmcgrath/twython/issues/184#issuecomment-16657751 > . ## Skype: ryanmcgrathr Twitter: http://twitter.com/ryanmcgrath/ Web: http://venodesigns.net/ GitHub: http://github.com/ryanmcgrath/
michaelhelmick commented 2013-04-19 10:15:23 -07:00 (Migrated from github.com)

@ryanmcgrath Looking at the function, it's not really dynamic. I got it to work with the current is.gd API, but we're forcing the param that is passed to the querysting, in master right now we're forcing the param query, what if the person uses bit.ly and their API does want the query parameter? You know what I mean?

Should I fix this to accept optional params so it can be dynamic, or should I fix it then raise a DeprecationWarning?

@ryanmcgrath Looking at the function, it's not really dynamic. I got it to work with the current is.gd API, but we're forcing the param that is passed to the querysting, in `master` right now we're forcing the param `query`, what if the person uses `bit.ly` and their API does want the `query` parameter? You know what I mean? Should I fix this to accept optional params so it can be dynamic, or should I fix it then raise a `DeprecationWarning`?
atrociousgrmblr commented 2013-04-19 10:21:23 -07:00 (Migrated from github.com)

@michaelhelmick I didn't make a pull request for that reason. I was thinking that changing params for is.gd might create problems for those who use another service that takes the query param.

@michaelhelmick I didn't make a pull request for that reason. I was thinking that changing params for `is.gd` might create problems for those who use another service that takes the `query` param.
michaelhelmick commented 2013-04-19 10:31:33 -07:00 (Migrated from github.com)

Well, is.gd now takes the param "url" instead of "query"

http://is.gd/create.php?format=json&url=http://google.com

But, my issue is that the method in Twython shortenUrl isn't dynamic.
If someone wanted to shorten for bit.ly they need to use "query", point being, differently URL shorteners take different params and shortenUrl isn't dynamic enough to handle them all.

The new method would look like

def shortenUrl(shortner='http://is.gd/create.php', **params):
    requests.get(shortner, params=params)
    ...... etc


short_url = Twython.shortenUrl(url='http://google.com', format='json')
print short_url

The method is broken anyways, so I don't see a problem in changing it.

Well, is.gd now takes the param "url" instead of "query" http://is.gd/create.php?format=json&url=http://google.com But, my issue is that the method in Twython `shortenUrl` isn't dynamic. If someone wanted to shorten for bit.ly they need to use "query", point being, differently URL shorteners take different params and `shortenUrl` isn't dynamic enough to handle them all. The new method would look like ``` python def shortenUrl(shortner='http://is.gd/create.php', **params): requests.get(shortner, params=params) ...... etc short_url = Twython.shortenUrl(url='http://google.com', format='json') print short_url ``` The method is broken anyways, so I don't see a problem in changing it.
michaelhelmick commented 2013-04-19 17:33:33 -07:00 (Migrated from github.com)

Then again, I feel like it's so ambiguous of a function.
What if the shortener they use doesn't return a JSON response, or only returns a normal text response.

I feel like there is no nice way to handle this without be so verbose in the method.

>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

I purpose nixing the function and letting the user handle their own shortening with requests unless you can think of a nice way to implement it @ryanmcgrath ?

Then again, I feel like it's so ambiguous of a function. What if the shortener they use doesn't return a JSON response, or only returns a normal text response. I feel like there is no nice way to handle this without be so verbose in the method. ``` >>> import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! ``` I purpose nixing the function and letting the user handle their own shortening with `requests` unless you can think of a nice way to implement it @ryanmcgrath ?
ryanmcgrath commented 2013-04-20 15:08:50 -07:00 (Migrated from github.com)

The function was a convenience method from when Twitter didn't automatically shorten URLs. Being that they do this now, it's not a particularly important thing for the purposes of the library. While I would like to keep it for legacy purposes, it might be time to just kill it off - with requests it's easy enough for a developer to sling it on their own anyway.

Deprecate it.

The function was a convenience method from when Twitter didn't automatically shorten URLs. Being that they do this now, it's not a particularly important thing for the purposes of the library. While I would like to keep it for legacy purposes, it might be time to just kill it off - with requests it's easy enough for a developer to sling it on their own anyway. Deprecate it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: repos/twython#184
No description provided.