Skip to content

Instantly share code, notes, and snippets.

@michelezonca
Created November 16, 2011 04:42
Show Gist options
  • Select an option

  • Save michelezonca/1369256 to your computer and use it in GitHub Desktop.

Select an option

Save michelezonca/1369256 to your computer and use it in GitHub Desktop.
# ...
# Call a method asynchronously and get a Thread object
thread = bitly.getShortenedUrl("http://www.mashape.com", "bitly-login", "bitly-api-key") { |response|
shortenedUrl = response["shortenedUrl"] # See the API's documentation
puts "Finally the shortened url is " + shortenedUrl
}
=begin
Do other stuff here. If you program ends here be sure to join the thread otherwise
you'll never see the response, because the main thread will end before the API call is executed
You can do this with: thread.join()
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment