我有一個簡單的應用程序,我想確認訂單從我的客戶反對通過短信購買。我將會話變量中的訂單ID傳遞給我,他將分別響應y或n來接受或拒絕訂單。我的代碼是一些這樣的事twilio會話變量不返回值
body = "You have a new order of a #{product.title}"
session[:orderId] = @order.id
client = Twilio::REST::Client.new(ACCOUNT_SID, AUTH_TOKEN)
client.account.messages.create(:from => 'myNo', :to => sotre_no, :body => body)
並獲得與
from = params["From"]
response = params["Body"]
order = Order.find session[:orderId] #session[:orderId] returns nil why?
if order.confirm(response)
body = "your order is confirmed! Thanks"
else
body = "You have reject the order Thanks for your response"
end
client = Twilio::REST::Client.new(ACCOUNT_SID, AUTH_TOKEN)
client.account.messages.create(:from => 'myNo', :to => from, :body => body)
響應回我不能夠得到訂單ID爲什麼任何一個可以幫助這個或建議我怎麼可以把訂單ID在params。
感謝您的回覆。我試過這個,但我認爲我們不能通過這種方式將參數傳遞給twilio api。 – 2014-10-31 13:54:03