Advertisement
kecoak

1419774098

Dec 28th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. <?php
  2.  
  3. /* Start session and load library. */
  4. session_start();
  5. require_once('../twitteroauth/twitteroauth.php');
  6. require_once('start.php');
  7.  
  8. /* Build TwitterOAuth object with client credentials. */
  9. $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
  10.  
  11. /* Get temporary credentials. */
  12. $request_token = $connection->getRequestToken(OAUTH_CALLBACK);
  13.  
  14. /* Save temporary credentials to session. */
  15. $_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
  16. $_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
  17.  
  18. /* If last connection failed don't display authorization link. */
  19. switch ($connection->http_code) {
  20. case 200:
  21. /* Build authorize URL and redirect user to Twitter. */
  22. $url = $connection->getAuthorizeURL($token);
  23. header('Location: ' . $url);
  24. break;
  25. default:
  26. /* Show notification if something went wrong. */
  27. echo 'Could not connect to Twitter. Refresh the page or try again later.';
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement