Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. class PostsController < ApplicationController
  2.  
  3. def create
  4. if params[:post_type] == "twitter"
  5. if twitter = current_user.authentications.find_by_provider("twitter")
  6. Twitter.configure do |tw|
  7. tw.consumer_key = "IKKOT98ZE5iJpLbQrno1Og"
  8. tw.consumer_secret = "mVkcL3B95tKXYS2VjwEJruvpIBB39pUUw7j7vsj8"
  9. tw.oauth_token = twitter.token
  10. tw.oauth_token_secret = twitter.token_secret
  11. end
  12. Twitter.update(params[:tweet])
  13. @message = "Your tweet successfully sent to Twitter."
  14. else
  15. @message = "Sorry, you first need to authenticate your Twitter acount."
  16. end
  17. elsif params[:post_type] == "facebook"
  18. if facebook = current_user.authentications.find_by_provider("facebook")
  19. me = FbGraph::User.me(facebook.token)
  20. me.feed!(
  21. :message => "#{params[:tweet]}",
  22. :link => 'http://moltosoldi.herokuapp.com',
  23. :name => 'The best way of keeping track of lends & borrows from Orhan Can Ceylan.',
  24. )
  25. @message = "Your post successfully sent to FaceBook."
  26. else
  27. @message = "Sorry, you first need to authenticate your FaceBook acount."
  28. end
  29. end
  30.  
  31.  
  32.  
  33. end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement