paste.xcode.ro » ~/paste/1003

  1. <?php
  2. /**
  3.  * @file
  4.  * User has successfully authenticated with Twitter. Access tokens saved to session and DB.
  5.  */
  6.  
  7. /* Load required lib files. */
  8. require_once('twitteroauth/twitteroauth.php');
  9. require_once('config.php');
  10.  
  11. /* If access tokens are not available redirect to connect page. */
  12. if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
  13.     header('Location: ./clearsessions.php');
  14. }
  15. /* Get user access tokens out of the session. */
  16. $access_token = $_SESSION['access_token'];
  17.  
  18. /* Create a TwitterOauth object with consumer/user tokens. */
  19. $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
  20.  
  21. /* If method is set change API call made. Test is called by default. */
  22. $content = $connection->get('account/verify_credentials');
  23.  
  24. /* Some example calls */
  25. //$connection->get('users/show', array('screen_name' => 'abraham')));
  26. //$connection->post('statuses/update', array('status' => date(DATE_RFC822)));
  27. //$connection->post('statuses/destroy', array('id' => 5437877770));
  28. //$connection->post('friendships/create', array('id' => 9436992)));
  29. //$connection->post('friendships/destroy', array('id' => 9436992)));
  30.  
  31. /* Include HTML to display on the page */
  32. include('html.inc');
  33.  
Language: php
Posted by husanu at 03 Aug 2011, 11:39:59 Europe/Bucharest