Created
August 15, 2008 07:32
-
-
Save zh/5554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Ping.fm to Rejaw Custom URL Script | |
# | |
# Before you can use, you will need to add the path of this file to | |
# the custom URL settings in your Ping.fm account: http://ping.fm/custom/. | |
# | |
# For further information on custom URL integration, check out the awesome help | |
# page: http://ping.fm/custom/help/ | |
# | |
# Register your application and get Rejaw API key from | |
# http://rejaw.com/developer/apps | |
# | |
# Ruby API: | |
# http://code.google.com/p/rejaw/source/browse/trunk/api/ruby/api_client.rb | |
require 'rubygems' | |
require 'api_client' | |
require 'ramaze' | |
BASE_URL = 'http://localhost:7000/'.freeze | |
# Ping.fm custom url: BASE_URL/PG_KEY | |
# example: http://localhost:7000/abcd | |
PG_KEY = 'abcd'.freeze | |
# Rejaw configuration | |
RJ_KEY = 'MyREJAWkey'.freeze | |
RJ_EMAIL = 'me@example.com'.freeze | |
RJ_PASS = 'SECret'.freeze | |
class MainController < Ramaze::Controller | |
def index t=nil | |
if t && (PG_KEY == t) && request.post? | |
rejaw = Rejaw::ApiClient.new(RJ_KEY, 0, 'api.rejaw.com') | |
rejaw.create_session | |
resp = rejaw.signin(RJ_EMAIL,RJ_PASS) | |
return "[E] can't post to Rejaw" unless resp[:succeeded] | |
rejaw.shout "[#{request[:method]}] #{request[:title]} #{request[:message]}" | |
rejaw.destroy_session | |
"message posted" | |
else | |
"not allowed" | |
end | |
end | |
Ramaze.start :port => 7000 if __FILE__ == $0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment