2010-07-03 48 views
0

我正在使用第三方API。該服務器應該回發到我的URL。爲我的XML獲取ActionController :: InvalidAuthenticityToken

我的網址是:

http://www.mydomain.com/teleku/playvoice.xml 

控制器具有一定的邏輯,但基本上包含的respond_to做塊和相應的視圖是一個非常基本的XML構建。

不過,我得到以下錯誤日誌:

的ActionController :: InvalidAuthenticityToken (ActionController的:: InvalidAuthenticityToken): HAML(2.2.17)[V] 的lib /上海社會科學院/插件/ rails.rb:19:in process_without_compass' compass (0.8.17) [v] lib/compass/app_integration/rails/action_controller.rb:7:in process'

+0

你能證明你做的POST請求到你的網址? – 2010-07-03 08:09:47

+0

嗨...嗯...我不知道我可以 - 它來自第三方請求...讓我看看teleku的文檔.....謝謝! – Angela 2010-07-03 15:07:54

回答

3

要禁用此檢查添加到您的控制器:

protect_from_forgery :except => [:your_method_name] 
0

OK。這就是我能想出:

舉例說明:

http://www.teleku.com/examples#highlowruby

從teleku提供的示例要點多數民衆贊成:

http://gist.github.com/raw/317657/38cd329895c79bd49e91304a6fe7cb1f88e02065/HighLow%20Ruby%20Sinatra%20Teleku%20PhoneML%20Voice%20Applications

它看起來就像沒有身份驗證令牌需要。所以你可以使用捲曲來測試,

curl --data-urlencode "callerinput=lower" http://highlow.heroku.com/guess/10 在那裏我的猜測是10,我的賭注低於經銷商隨機選擇的數字。 它的工作原理。但是,如果你想讓它在你的應用程序中工作,你應該將真實性標記編碼到URL中。例如,如果相同的應用程序已經protect_from_forgery啓用,那麼這將是:

curl --data-urlencode "callerinput=lower&authenticity_token=blahblahblah" http://highlow.heroku.com/guess/10"

相關問題