You are here

function jquery_social_stream_twitter_callback in jQuery social stream 7

Same name and namespace in other branches
  1. 7.2 jquery_social_stream.js.inc \jquery_social_stream_twitter_callback()

Twitter callback for social stream.

2 string references to 'jquery_social_stream_twitter_callback'
jquery_social_stream_js in ./jquery_social_stream.module
Implements hook_js().
jquery_social_stream_menu in ./jquery_social_stream.module
Implements hook_menu().

File

./jquery_social_stream.js.inc, line 10
JS callbacks.

Code

function jquery_social_stream_twitter_callback() {
  $keys = _jquery_social_stream_vars_get(array(
    'jquery_social_stream_twitter_api_key',
    'jquery_social_stream_twitter_api_secret',
    'jquery_social_stream_twitter_access_token',
    'jquery_social_stream_twitter_access_token_secret',
  ));
  $consumer_key = $keys['jquery_social_stream_twitter_api_key'];
  $consumer_secret = $keys['jquery_social_stream_twitter_api_secret'];
  $oauth_access_token = $keys['jquery_social_stream_twitter_access_token'];
  $oauth_access_token_secret = $keys['jquery_social_stream_twitter_access_token_secret'];
  switch ($_GET['url']) {
    case 'timeline':
      $rest = 'statuses/user_timeline';
      $params = array(
        'count' => $_GET['count'],
        'include_rts' => $_GET['include_rts'],
        'exclude_replies' => $_GET['exclude_replies'],
        'screen_name' => $_GET['screen_name'],
      );
      break;
    case 'search':
      $rest = "search/tweets";
      $params = array(
        'q' => $_GET['query'],
        'count' => $_GET['count'],
        'include_rts' => $_GET['include_rts'],
      );
      break;
    case 'list':
      $rest = "lists/statuses";
      $params = array(
        'list_id' => $_GET['list_id'],
        'count' => $_GET['count'],
        'include_rts' => $_GET['include_rts'],
      );
      break;
    default:
      $rest = 'statuses/user_timeline';
      $params = array(
        'count' => '20',
      );
      break;
  }
  $auth = new TwittersOAuth($consumer_key, $consumer_secret, $oauth_access_token, $oauth_access_token_secret);
  $get = $auth
    ->get($rest, $params);
  if (!$get) {
    echo 'An error occurs while reading the feed, please check your connection or settings';
  }
  if (isset($get->errors)) {
    foreach ($get->errors as $key => $val) {
      echo $val;
    }
  }
  else {
    echo $get;
  }
}