Topic: https://brettterpstra.com/2014/04/30/bitlyize-link-shortening-service/
hide preview

What's next? verify your email address for reply notifications!

Aaron Bach 10y, 324d ago

FYI, a couple of errors in that script, both in the create_query method:

1. `data['access_token'] = @apikey` needs to be `data['apiKey'] = @apikey`
2. You need to add a `data[login]` value.

https://gist.github.com/bac...

remark link
hide preview

What's next? verify your email address for reply notifications!

ttscoff 10y, 324d ago

Why is everyone trying to annoy me today? Use the Legacy API Key and you don't need a login.

remark link parent
hide preview

What's next? verify your email address for reply notifications!

ttscoff 10y, 324d ago

Sorry, that was snippy, but the script is fully tested and works as is. The instructions are correct.

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Aaron Bach 10y, 324d ago

When you follow your instructions and turn on debug, this is what you get:

"{ \"data\": [ ], \"status_code\": 500, \"status_txt\": \"INVALID_ARG_ACCESS_TOKEN\" }"

(And yes, I'm using my legacy API key).

So, looking at their API docs - http://dev.bitly.com/authen... - they specify that for the deprecated API key authentication method, you need two parameters: `login` and `apiKey` (not `access_token`).

Just trying to help. I trust that it's fully tested on your side, but I followed your instructions to the T and it didn't work.

remark link parent

load more (1 remarks)
hide preview

What's next? verify your email address for reply notifications!

ttscoff 10y, 324d ago

I appreciate it, sorry for getting dickish about it. I've been using this script for a year and have never had an issue (and don't get that error message when I run it in debug). I'll test with your changes and if it works fine and prevents problems for others, I'll update.

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Aaron Bach 10y, 324d ago

No problem. :) One interesting thing to consider: which version of Ruby are you running? I'm using 2.1.1, so maybe some differences exist there...

remark link parent
hide preview

What's next? verify your email address for reply notifications!

ttscoff 10y, 324d ago

Ok, first, the legacy API key shown changed to match the new requirements, but I had my old API key which didn't require a username and it was still functioning. I didn't realize no one could get those anymore. So you're correct, and an updated version of the script will be up shortly.

Are you saying you replaced your system ruby with an updated version? That's not a great idea, better off using rbenv or rvm to run multiple environments. The Service will always use the system Ruby, which on Mavericks should be 2.0 and 1.8.7 on earlier OS X versions. Thus, I'm running 2.0, but tested on 1.8.7 and 1.9 as well. Can't account for 2.1+.

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Aaron Bach 10y, 324d ago

Got it!

Allow me to clarify: I did not replace the system Ruby -- I'm using RVM. Nothing in your script screams version problems, though, so based on what you discovered, disregard.

hide preview

What's next? verify your email address for reply notifications!

Bin Yang 10y, 324d ago

“The only configuration required is a Bitly API key”, it seemed that the key should be Access Token.

remark link
hide preview

What's next? verify your email address for reply notifications!

ttscoff 10y, 324d ago

As clearly stated, this uses the Legacy API Key available under advanced settings in your bit.ly account. It does no oAuth.

hide preview

What's next? verify your email address for reply notifications!

Brad Choate 10y, 324d ago

There's a PopClip extension for this too: https://pilotmoon.com/popcl...

remark link
hide preview

What's next? verify your email address for reply notifications!

ttscoff 10y, 324d ago

The difference, I believe, is that this will work on multiple urls and urls contained within text, as well as the iTunes affiliate feature.

hide preview

What's next? verify your email address for reply notifications!

David Friedman 10y, 324d ago

FWIW, in case people don't know about this option: you can also use TextExpander to easily create bit.ly links. They have an "Internet Productivity" snippets group available for download that includes "/bitly" as a snippet. Just copy a URL, type the snippet, and it will be replaced by a bit.ly link. I use it all the time.

remark link
hide preview

What's next? verify your email address for reply notifications!

ttscoff 10y, 324d ago
hide preview

What's next? verify your email address for reply notifications!