views:

89

answers:

0

I am using twitter_oauth gem for Rails to implement Twitter posting feature. I currently got my app to ask the user for Deny/Allow access of my app. However, after that when I try to publish, nothing happens. And, as I debug, I got the following error

request: /1/statuses/update.json
error: Invalid / expired Token

I believe the consumer info is correct but I do not know what is wrong with the secret_token and request_token

here is my FacebookController Code

class TwitterController < ApplicationController

  def index
    render :nothing => true
  end
  def start
    oauth_confirm_url = "http://localhost:3000/twitter/callback/"
    request_token = twitter_client.request_token(:oauth_callback => oauth_confirm_url)
    session[:request_token] = request_token.token
    session[:request_token_secret] = request_token.secret
    redirect_to request_token.authorize_url
  end
  def callback
    access_token = twitter_client.authorize(
      session[:request_token],
      session[:request_token_secret],
      :oauth_verifier => params[:oauth_verifier]
    )

    if twitter_client.authorized?
      session[:access_token] = access_token.token
      session[:secret_token] = access_token.secret
    else

    end
    redirect_to (url_for :controller => 'twitter', :action => 'publish', :update => "Testing")
  end
  def publish
    @client = TwitterOAuth::Client.new(
              :consumer_key => 'SECRET',
              :consumer_secret => 'SECRET',
              :token => session[:access_token],
              :secret => session[:secret_token]
            )
    render 'publish'
  end
end

my publish.html.erb which show error: Invalid / expired Token

<h1>Your status is updated on Twitter</h1>
<%= debug(params) %>
<%= debug(session) %>
<%= debug(@client.update(params[:update])) #Shows error: Invalid / expired Token %>