function post_twitt_news($id_news) { if (Nw::$is_prod && isset(Nw::$twitter['nouweo']) && count(Nw::$twitter['nouweo']) > 0) { inc_lib('news/get_info_news'); $donnees_news = get_info_news($id_news); $real_link_news = Nw::$site_url . $donnees_news['c_rewrite'] . '/' . rewrite($donnees_news['n_titre']) . '-' . $id_news . '/'; $fields = array('source' => $real_link_news); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://shr.im/api/post/'); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $fields); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($curl); curl_close($curl); $end_twitt = ' http://shr.im/' . $result . ' #' . strtolower(Nw::$site_name) . ' #' . strtolower($donnees_news['c_rewrite']); $longueur_twitt = 145 - strlen($end_twitt); if ($donnees_news['n_titre'] > $longueur_twitt) { $add_titre = CoupeChar($donnees_news['n_titre'], '...', $longueur_twitt); } else { $add_titre = $donnees_news['n_titre']; } $twitt2post = $add_titre . $end_twitt; // Postage du twitt sur le compte de base $to = new TwitterOAuth(Nw::$twitter['nouweo']['consumer_key'], Nw::$twitter['nouweo']['consumer_secret'], Nw::$twitter['nouweo']['token'], Nw::$twitter['nouweo']['token_secret']); $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => $twitt2post), 'POST'); return $result; } else { return false; } }
function twitter_oauth_login_test(&$vars) { extract($vars); $success = false; $TwitterUser =& $db->model('TwitterUser'); $tu = $TwitterUser->find_by(array('profile_id' => get_profile_id()), 1); if ($tu) { // http://abrah.am if (!class_exists('oauthexception')) { lib_include('twitteroauth'); } $key = $tu->oauth_key; $secret = $tu->oauth_secret; $consumer_key = environment('twitterKey'); $consumer_secret = environment('twitterSecret'); $to = new TwitterOAuth($consumer_key, $consumer_secret, $tu->oauth_key, $tu->oauth_secret); $timelineurl = 'https://twitter.com/statuses/friends_timeline.atom'; $response = $to->OAuthRequest($timelineurl, array(), 'GET'); if (strpos($response, '<subtitle>')) { $success = true; } } if ($success) { echo 1; } else { echo 0; } exit; }
protected function tweet($mes) { require_once "lib/twitteroauth/twitteroauth.php"; $consumer_key = "zK7Gjax5bz4dwquQlQjpMqrNn"; $consumer_secret = "D7WRu7OETyDwzrp5hFeWGYOUNOJQSJkyUWGjOBznjXf8pvQi2s"; $access_token = "228073867-VUbEHWJfbfuRVAZ9iP5x18Xa2Wg8NwBVU4ePxhNA"; $access_token_secret = "tvwFm63YXaaMBA3OJE7BpS0NyGd3lgVM5zSusiXBaDxJV"; $to = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret); $req = $to->OAuthRequest("https://api.twitter.com/1.1/statuses/update.json", "POST", array("status" => $mes)); }
function getTweets($keyword) { // twitteroauthのインスタンス生成 $twitterOAuth = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); // APIに渡すパラメータを設定 $param = array("q" => $keyword, "lang" => "ja", "count" => 10, "result_type" => "recent"); // TwitterのAPIへ $json = $twitterOAuth->OAuthRequest("https://api.twitter.com/1.1/search/tweets.json", "GET", $param); // jsonデコードして返す return json_decode($json, true); }
/** * url http://api.twitter.com/1/statuses/home_timeline.xml */ function twitterApi($id, $url, $method = "GET", $param = array()) { $token = $this->getOAuthToken($id); $conKey = $token['con_key']; $conScr = $token['con_secret']; $conKey = $this->Ctrl->getConf('twitter.key'); $conScr = $this->Ctrl->getConf('twitter.secret'); $acToken = $token['token']; $acScr = $token['token_secret']; $oa = new TwitterOAuth($conKey, $conScr, $acToken, $acScr); return $oa->OAuthRequest($url, $method, $param); }
public function get($owner, $list) { // Unfortunately, the GET LIST MEMBERS API requires authentication for // some reason, even when the same data is available on the website. So // this requires hard-coding (or otherwise storing) a user's OAuth // credentials in here. Be sure that the application has read-only // permissions to reduce the chance of tomfoolery. $oauth = new TwitterOAuth(self::CONSUMER_KEY, self::CONSUMER_SECRET, self::OAUTH_TOKEN, self::OAUTH_SECRET); $response = $oauth->OAuthRequest("https://api.twitter.com/1.1/lists/members.json", array('slug' => $list, 'owner_screen_name' => $owner), 'GET'); $members = json_decode($response); usort($members->users, array(self, 'lastUpdated')); return $members->users; }
public function TweetSearchGet($word, $count, $option = null) { $optionset = array('q' => $word, 'count' => $count, 'lang' => 'ja', "result_type" => "recent"); if (!is_null($option)) { $optionset += $option; } $optioncache = implode(",", $optionset); if (!$this->Cacheing($optioncache, TRUE, "html")) { $nicotwitter = new TwitterOAuth($this->consumerKey, $this->consumerSecret, $this->accessToken, $this->accessTokenSecret); $json = $nicotwitter->OAuthRequest('https://api.twitter.com/1.1/search/tweets.json', 'GET', $optionset); $this->Cacheing($optioncache, FALSE, $json, 360); unset($nicotwitter); } else { $json = $this->Cacheing($optioncache, TRUE, "html"); } $jset = json_decode($json, true); if (!isset($jset['errors'])) { $this->tweetssearchinfo['flag'] = TRUE; $this->tweetssearchinfo['maxid'] = (string) $jset['search_metadata']['max_id_str']; $this->tweetssearchinfo['since_id'] = $jset['search_metadata']['since_id_str']; if (is_array($jset['statuses'])) { foreach ($jset['statuses'] as $i => $item) { $this->tweetssearchinfo[$i]['id'] = $item['id_str']; $this->tweetssearchinfo[$i]['username'] = $item['user']['name']; $this->tweetssearchinfo[$i]['userid'] = $item['user']['id_str']; $this->tweetssearchinfo[$i]['screen_name'] = $item['user']['screen_name']; $this->tweetssearchinfo[$i]['profile_img'] = $item['user']['profile_image_url']; $this->tweetssearchinfo[$i]['text'] = $item['text']; $this->tweetssearchinfo[$i]['time'] = date("Y-m-d H:i:s", strtotime($item['created_at'])); if (is_array($item['entities'])) { if (is_array($item['entities']['hashtags'])) { foreach ($item['entities']['hashtags'] as $j => $val) { $this->tweetssearchinfo[$i]['hashtags'][$j] = $val['text']; } } if (is_array($item['entities']['urls'])) { foreach ($item['entities']['urls'] as $j => $val) { $this->tweetssearchinfo[$i]['expanded_url'][$j] = $val['expanded_url']; } } } } } } else { $this->tweetssearchinfo['flag'] = FALSE; } }
function handleTwitterAuthentication($state) { global $session; /* * 'default': Get a request token from Twitter for new user * 'returned': The user has authorized the app on Twitter and been returned */ switch ($state) { case 'returned': $userDetailsJSON = NULL; try { $to = new TwitterOAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, $_SESSION['oauthRequestToken'], $_SESSION['oauthRequestTokenSecret']); $tok = $to->getAccessToken(); $userDetails = $to->OAuthRequest('https://twitter.com/account/verify_credentials.json', array(), 'GET'); } catch (Exception $e) { /*echo '01 - '.$e->getMessage(); debugDump(); exit();*/ header("Location: logout.php"); } $userDetailsJSON = json_decode($userDetails); $session->loggedIn = $session->createSession($userDetailsJSON->id, $tok['oauth_token'], $tok['oauth_token_secret'], $userDetailsJSON); if (!$session->loggedIn) { /*echo '02'; debugDump(); exit();*/ header('Location: logout.php'); } break; default: try { $to = new TwitterOAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET); $tok = $to->getRequestToken(); } catch (Exception $e) { /*echo '02'; debugDump(); exit();*/ header('Location: logout.php'); } $_SESSION['oauthRequestToken'] = $token = $tok['oauth_token']; $_SESSION['oauthRequestTokenSecret'] = $tok['oauth_token_secret']; $_SESSION['oauthState'] = "start"; $oAuthRequestLink = $to->getAuthorizeURL($token); include 'tmp/account/login.php'; break; } }
public function _tweet($tweet) { // OAuthスクリプトの読み込み //require_once('../webroot/files/twitteroauth/twitteroauth/twitteroauth.php''); require_once 'D:\\home\\site\\wwwroot\\app\\webroot\\files\\twitteroauth\\twitteroauth\\twitteroauth.php'; // Consumer key $consumer_key = "HpHdBxp6ZdvQDdSunB8pG6tz1"; // Consumer secret $consumer_secret = "Z0OBWi5ukA7OS8M55Skm04tmy21ZJhwNi1GclElZRd9Ki0iVeh"; // Access token $access_token = "2904456636-l686WIpsrAEggQWDiPlOGz1pPtlicgRP0LqcLyw"; // Access token secret $access_token_secret = "uYf6mtHvmVQ3uW6KOSrIrB2fQzavILQUBhPexjIbxOEAx"; // とりあえず、Twitterの文字制限のことは無視して // つぶやく $connection = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret); $req = $connection->OAuthRequest("https://api.twitter.com/1.1/statuses/update.json", "POST", array("status" => $tweet)); }
function send_to_twitter(&$model, &$rec) { if (!get_profile_id()) { return; } // if the Record does not have a title or uri, bail out if (!isset($rec->title) || !isset($rec->uri)) { return; } if (get_option('twitter_status') != 'enabled') { return; } global $db, $prefix; $sql = "SELECT oauth_key,oauth_secret FROM " . $prefix . "twitter_users WHERE profile_id = " . get_profile_id(); $result = $db->get_result($sql); if ($db->num_rows($result) == 1) { // http://abrah.am lib_include('twitteroauth'); $key = $db->result_value($result, 0, 'oauth_key'); $secret = $db->result_value($result, 0, 'oauth_secret'); $consumer_key = environment('twitterKey'); $consumer_secret = environment('twitterSecret'); $to = new TwitterOAuth($consumer_key, $consumer_secret, $key, $secret); $notice_content = substr($rec->title, 0, 140); $content = $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => $notice_content), 'POST'); } else { wp_plugin_include('twitter-tools'); // set a flag on aktt global $aktt; $aktt->tweet_from_sidebar = false; // truncate the tweet at 140 chars $notice_content = substr($rec->title, 0, 140); // activate Twitter Tools $_GET['activate'] = true; // trip the init() function aktt_init(); // make a new tweet object $tweet = new aktt_tweet(); // set the tweetbody $tweet->tw_text = stripslashes($notice_content); // send the tweet to Twitter $aktt->do_tweet($tweet); } }
public static function tweet($message) { // This always tweets as the current user, who must be // logged in via Twitter. TODO: support tweeting as any user; // keep twitter access tokens handy in a database table, since they never expire. // Break out the parts of this method that are generic to all API calls // we might want to make. $user = sfContext::getInstance()->getUser(); if (!$user->isAuthenticated()) { return false; } /* Create TwitterOAuth with app key/secret and user access key/secret */ $consumer_key = sfConfig::get('app_sfTwitterAuth_consumer_key'); $consumer_secret = sfConfig::get('app_sfTwitterAuth_consumer_secret'); $to = new TwitterOAuth($consumer_key, $consumer_secret, $user->getAttribute('sfTwitterAuth_oauth_access_token'), $user->getAttribute('sfTwitterAuth_oauth_access_token_secret')); /* Run request on twitter API as user. */ $result = $to->OAuthRequest('http://twitter.com/statuses/update.xml', array("status" => $message), 'POST'); $xml = simplexml_load_string($result); $created_at = $xml->xpath("descendant::screen_name"); if (!$created_at) { return false; } return true; }
$to = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret); $url = 'http://api.flickr.com/services/feeds/photos_public.gne?id=' . $f_id . '&lang=en-us&format=rss_200'; // 投稿するRSS $rss = file_get_contents($url); $oXML = simplexml_load_string($rss); $oItems = $oXML->channel->item; $i = 0; foreach ($oItems as $Item) { if ($i >= CHECK_RSS_COUNT) { break 1; } if (!PostCheck($Item->link, $file)) { $sLink = Shorten($Item->link); $text = $Item->title . " " . $sLink; // ツイート文言 $res = $to->OAuthRequest("http://api.twitter.com/1/statuses/update.xml", "POST", array("status" => $text)); // 成功したらfileに書き込む file_put_contents($file, (string) $Item->link); } $i++; } // twitterAPIの返りオブジェクト,RSSオブジェクトのタイトル function PostCheck($sHead, $file) { $sHead = (string) $sHead; // fileから最後に投稿したlinkとマッチするかチェック if (mb_strpos(file_get_contents($file), $sHead) !== false) { return 1; // 投稿済み } return 0;
} // check if it's a private source or if we are rerouting with oAuth if ($_GET['private'] || $tb_o['advanced_reroute_on'] && $tb_o['advanced_reroute_type'] == 'oauth') { // check to make sure we have the class if (!class_exists('TwitterOAuth')) { echo $json->encode(array('error' => 'Twitter oAuth is not available')); exit; } // make sure we have oAuth info if (!isset($tb_o['oauth_access_token'])) { echo $json->encode(array('error' => "Don't have oAuth login info")); exit; } else { // try to get it directly $oAuth = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $tb_o['oauth_access_token']['oauth_token'], $tb_o['oauth_access_token']['oauth_token_secret']); $json_data = $oAuth->OAuthRequest($url, 'GET', $params); if ($oAuth->http_code == 200) { echo $json_data; // update cache if (!$tb_o['advanced_disable_cache']) { $data = $json->decode($json_data); if (isset($data->results)) { $tweets = $data->results; } else { $tweets = $data; } tb_save_cache($sources, $tweets); } exit; } else { if ($json_data = tb_get_cached_tweets_json($sources)) {
function verifyCredentials() { $request = 'http://twitter.com/account/verify_credentials.xml'; $to = new TwitterOAuth($_SESSION['consumer_key'], $_SESSION['consumer_secret'], $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']); $xml = new SimpleXMLElement($to->OAuthRequest($request, array(), 'GET')); $user = new User($xml); return $user; }
} // アプリ登録した際に発行された値を入れて下さい。 $consumer_key = 'klE1y49JpMpxcwyK8FqL0Sl9t'; $consumer_secret = '21FJWI4uX1ClShZfrjU2qOyq7K1fBIuXHdt1kuPw3qWCcC0AEH'; $access_token = $_SESSION['oauthToken']; $access_token_secret = $_SESSION['oauthTokenSecret']; // オブジェクト生成 $tw_obj = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret); // REST_API指定(今回はタイムラインのREST_API) $tw_rest_api = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; // メソッド指定 $request_method = 'GET'; // オプション指定 $options = array('count' => 200, 'include_entities' => true); // ユーザータイムライン取得 $tw_obj_request = $tw_obj->OAuthRequest($tw_rest_api, $request_method, $options); // json形式で取得 $tw_obj_request_json = json_decode($tw_obj_request, true); // 変数生成 $time_line_texts = ''; header("Content-Type: application/json; charset=utf-8"); $str = ''; $pic1 = ""; $pic2 = ""; echo '['; // 取得したデータを回して入れていく、さらにjson形式で出力 foreach ($tw_obj_request_json as $key => $value) { //位置情報の有無を確認する、ユーザー名取得 if (isset($value['place']['full_name'])) { $user_name = $value['user']['screen_name']; $name = $value['user']['name'];
$mode = $_GET["mode"]; include "./twitterOAuth.php"; if ($_COOKIE["etk_s"] != "") { $cookie = explode("<>", $_COOKIE["etk_s"]); } // Consumer key $consumer_key = "ZzGL1zpvWPkWlswUpFQ8AaB40"; // Consumer secret $consumer_secret = "CNK0V3kYjO7COwJ4fj7THqW46Ofpt75MkquGEdboJvFKGbfxPn"; // Access Token $access_token = $cookie[0]; // Access Token Secret $access_token_secret = $cookie[1]; $to = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret); if ($mode == "") { $req = $to->OAuthRequest("https://api.twitter.com/1.1/direct_messages.json", "GET", array("count" => "15")); $result = json_decode($req, true); //print_r($result); $a = 0; if ($result[errors][0][message] == "Rate limit exceeded") { echo "DM一覧の取得に失敗"; exit; } echo '<a href="./dm.php">更新</a><hr>'; while ($a < count($result)) { $twi_list = $result[$a]; $dm_me = $twi_list[text]; $dm_rec[name] = $twi_list[sender][name]; $dm_rec[id] = $twi_list[sender][screen_name]; $dm_rec[id_str] = $twi_list[sender][id_str]; $dm_time = date("Y/m/d H:i:s", strtotime($twi_list[created_at]));
function show_form() { $user_pref = $this->func->get_user_pref($this->uid); $disabled = array(); if ($this->root->twitter_consumer_key && $this->root->twitter_consumer_secret && function_exists('curl_init') && version_compare(PHP_VERSION, '5.0.0', '>') && HypCommonFunc::get_version() >= '20100108') { HypCommonFunc::loadClass('TwitterOAuth'); $state = isset($_SESSION['oauth_state']) ? $_SESSION['oauth_state'] : ''; if (!empty($user_pref['twitter_access_token']) && !empty($user_pref['twitter_access_token_secret'])) { $to = new TwitterOAuth($this->root->twitter_consumer_key, $this->root->twitter_consumer_secret, $user_pref['twitter_access_token'], $user_pref['twitter_access_token_secret']); $content = $to->OAuthRequest('https://twitter.com/account/verify_credentials.xml', 'GET', array()); if (strpos($content, '<error>') === FALSE) { $state = 'ok'; } else { $user_pref['twitter_access_token'] = ''; $user_pref['twitter_access_token_secret'] = ''; } } if (!empty($this->root->get['oauth_token']) && $state === 'start') { $state = 'returned'; unset($_SESSION['oauth_state']); } if (isset($this->root->get['denied'])) { $state = 'denied'; unset($_SESSION['oauth_state']); } switch ($state) { case 'returned': $to = new TwitterOAuth($this->root->twitter_consumer_key, $this->root->twitter_consumer_secret, $_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']); $tok = $to->getAccessToken($this->root->get['oauth_verifier']); $user_pref['twitter_access_token'] = $tok['oauth_token']; $user_pref['twitter_access_token_secret'] = $tok['oauth_token_secret']; $this->msg['twitter_access_token_secret']['description'] = ''; break; case 'denied': $user_pref['twitter_access_token'] = ''; $user_pref['twitter_access_token_secret'] = ''; $this->msg['twitter_access_token_secret']['description'] = ''; break; case 'ok': $this->msg['twitter_access_token_secret']['description'] = ''; break; default: $to = new TwitterOAuth($this->root->twitter_consumer_key, $this->root->twitter_consumer_secret); $tok = $to->getRequestToken($this->root->script . '?cmd=user_pref'); if (!empty($tok['oauth_token'])) { $_SESSION['oauth_request_token'] = $token = $tok['oauth_token']; $_SESSION['oauth_request_token_secret'] = $tok['oauth_token_secret']; $_SESSION['oauth_state'] = "start"; $this->root->twitter_request_link = $to->getAuthorizeURL($token); } else { $disabled['twitter'] = true; } break; } } else { $disabled['twitter'] = true; } if (!empty($disabled['twitter'])) { unset($this->user_pref['twitter_access_token'], $this->user_pref['twitter_access_token_secret']); } // moblog if (!$this->root->use_moblog_user_pref) { unset($this->user_pref['moblog_mail_address'], $this->user_pref['moblog_base_page'], $this->user_pref['moblog_user_mail'], $this->user_pref['moblog_to_twitter'], $this->user_pref['moblog_auth_code']); } else { if (strpos($this->root->moblog_pop_mail, '*') === false) { unset($this->user_pref['moblog_user_mail']); } else { unset($this->user_pref['moblog_mail_address']); if (empty($user_pref['moblog_user_mail'])) { $user_tag = strtolower($this->make_user_tag()); $user_pref['moblog_user_mail'] = str_replace('*', $user_tag, $this->root->moblog_pop_mail); } $this->root->moblog_user_mail = htmlspecialchars($user_pref['moblog_user_mail']); $this->root->moblog_user_mail_rawurlenc = rawurlencode($user_pref['moblog_user_mail']); } if (!$user_pref['twitter_access_token']) { unset($this->user_pref['moblog_to_twitter']); } } // XML-RPC if (!$this->root->use_xmlrpc) { unset($this->user_pref['xmlrpc_pages'], $this->user_pref['xmlrpc_auth_key'], $this->user_pref['xmlrpc_to_twitter']); } else { if (empty($user_pref['xmlrpc_pages'])) { // Read user config $pages = array(); $config = new XpWikiConfig($this->xpwiki, $this->cont['PKWK_CONFIG_USER'] . '/' . $this->root->userinfo['uname']); $table = $config->read() ? $config->get('XML-RPC') : array(); foreach ($table as $row) { if (isset($row[1]) && strtolower(trim($row[0])) === 'myblog') { $page = $this->func->strip_bracket(trim($row[1])); $pages[] = htmlspecialchars($page); } } $user_pref['xmlrpc_pages'] = join("\n", $pages); } if (empty($user_pref['xmlrpc_auth_key'])) { $user_pref['xmlrpc_auth_key'] = substr($this->make_user_tag(), 0, 8); } if (!$user_pref['twitter_access_token']) { unset($this->user_pref['xmlrpc_to_twitter']); } } $script = $this->func->get_script_uri(); if ($this->user_pref) { $body = <<<EOD <div> <h2>{$this->msg['title_description']}</h2> {$this->msg['msg_description']} </div> <hr /> <div class="user_pref"> <form action="{$script}" method="post"> <table> EOD; //var_dump($user_pref); //exit; foreach ($this->user_pref as $key => $conf) { $caption = !empty($conf['caption']) ? $conf['caption'] : (!empty($this->msg[$key]['caption']) ? $this->msg[$key]['caption'] : $key); $description = !empty($conf['description']) ? $conf['description'] : (!empty($this->msg[$key]['description']) ? $this->msg[$key]['description'] : ''); $description = preg_replace('/\\{\\$root->(.+?)\\}/e', '$this->root->$1', $description); $value = isset($user_pref[$key]) ? $user_pref[$key] : ''; $value4disp = htmlspecialchars($value); $name4disp = htmlspecialchars($key); $real = ''; $extention = !empty($this->msg[$key]['extention']) ? $this->msg[$key]['extention'] : ''; list($form, $attr) = array_pad(explode(',', $conf['form'], 2), 2, ''); switch ($form) { case 'select': $forms = array(); if (!isset($conf['list']['group'])) { $conf['list']['group'][0] = $conf['list']; } foreach ($conf['list']['group'] as $label => $optgroup) { if (is_string($label)) { $forms[] = '<optgroup label="' . $label . '">'; } foreach ($optgroup as $list_cap => $list_val) { if ($value == $list_val) { $selected = ' selected="selected"'; } else { $selected = ''; } $forms[] = '<option value="' . $list_val . '"' . $selected . '>' . $list_cap . '</option>'; } if (is_string($label)) { $forms[] = '</optgroup>'; } } $form = '<select name="' . $name4disp . '" ' . $attr . '>' . join('', $forms) . '</select>'; break; case 'yesno': $conf['list'] = array($this->msg['Yes'] => 1, $this->msg['No'] => 0); case 'radio': $forms = array(); $i = 0; foreach ($conf['list'] as $list_cap => $list_val) { if ($value == $list_val) { $checked = ' checked="checked"'; } else { $checked = ''; } $forms[] = '<span class="nowrap"><input id="' . $name4disp . '_' . $i . '" type="radio" name="' . $name4disp . '" value="' . $list_val . '"' . $checked . ' /><label for="' . $name4disp . '_' . $i . '">' . $list_cap . '</label></span>'; $i++; } $form = join(' | ', $forms); break; case 'textarea': $form = '<textarea name="' . $name4disp . '" ' . $attr . ' rel="nowikihelper">' . $value4disp . '</textarea>'; break; case 'hidden': $form = '<input type="hidden" name="' . $name4disp . '" value="' . $value4disp . '" />' . $value4disp; break; case 'text': default: $style = ''; if ($conf['type'] === 'integer' || $conf['type'] === 'integer!0') { $style = ' style="text-align:right;"'; } $form = '<input type="text" name="' . $name4disp . '" value="' . $value4disp . '" ' . $attr . $style . ' />'; } $body .= <<<EOD <tr> <td style="font-weight:bold;padding-top:0.5em" id="{$key}">{$caption}</td> <td style="padding-top:0.5em">{$form}{$extention}</td> </tr> <tr style="border-bottom:1px dotted gray;"> <td colspan="2" style="padding-bottom:0.5em"><p>{$description}</p></td> </tr> EOD; } $body .= <<<EOD <tr> <td> </td> <td><input type="submit" name="submit" value="{$this->msg['btn_submit']}" /></td> </tr> </table> <input type="hidden" name="plugin" value="user_pref" /> <input type="hidden" name="pmode"\t value="post" /> </form> </div> EOD; } else { $body = 'There is no item.'; } return array('msg' => $this->msg['title_form'], 'body' => $body); }
<?php //twitteroaAuth.phpと設定ファイルを読み込む。パスはあなたが置いた適切な場所に変更してください require_once 'twitteroauth/twitteroauth.php'; require_once "setting.php"; //OAuthオブジェクト生成 $to = new TwitterOAuth($consumer_key, $consumer_secret, $access_token, $access_token_secret); //ここから投稿する文章制作 $mes = "こんにちは!世界!"; //投稿 $req = $to->OAuthRequest("https://twitter.com/statuses/update.xml", "POST", array("status" => $mes));
public function twitterGetLoggedinUserInfo($token = '', $secret = '') { include_once $this->config['twitter_library_path']; $data = ''; try { $to = new TwitterOAuth($this->config['twitter_consumer'], $this->config['twitter_secret'], $token, $secret); $data = simplexml_load_string($to->OAuthRequest('http://api.twitter.com/1/account/verify_credentials.xml', '', 'GET')); } catch (Exception $o) { print_r($o); } return $data; }
$token['oauth_token'] = $session_request_token; $token['oauth_request_token_secret'] = $session_request_token_secret; } /* Create Twitter OAuth Login URL */ $twitter_oauth_link = "https://twitter.com/oauth/authorize?oauth_token={$token["oauth_token"]}"; } else { if ($oauth_token != "") { $to = new TwitterOAuth($consumer_key, $consumer_secret, $session_request_token, $session_request_token_secret); $token = $to->getAccessToken(); /* Save OAuth Access Tokens */ $_SESSION['oauth_access_token'] = $token['oauth_token']; $_SESSION['oauth_access_token_secret'] = $token['oauth_token_secret']; /* Create new TwitterOAuth Object to send Requests */ $to = new TwitterOAuth($consumer_key, $consumer_secret, $token['oauth_token'], $token['oauth_token_secret']); /* Create a new OAuth Request for User Information. */ $response = $to->OAuthRequest('https://twitter.com/account/verify_credentials.xml', array(), 'GET'); $xml = simplexml_load_string($response); $screen_name = $xml->screen_name[0]; $name = $xml->name[0]; $_SESSION["username"] = strip_tags($screen_name); $_SESSION["name"] = strip_tags($name); $database = new MysqlDatabase(dbHost, dbUser, dbPass, dbName); $database->SetQuery("SELECT * FROM `table_messages` WHERE message_name='share_deal_twitter'"); $share_message = $database->DoQuery(); $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => $share_message[0]["message"]), 'POST'); $to->OAuthRequest('http://twitter.com/friendships/create/callatt.xml?follow=true', array(), 'POST'); $database->SetQuery("SELECT * FROM `table_credits` WHERE user_id_credited='{$_SESSION["user-data"]["user_id"]}'"); $check = $database->CountDBResults(); if (!$check) { // user has not been credited $10 yet $database->SetQuery("INSERT INTO `table_credits` VALUES ('','{$_SESSION["user-data"]["user_id"]}')");
<?php require_once 'lib/twitter_init.php'; require_once 'lib/init.php'; if ($_REQUEST['message'] != "" && isset($_REQUEST['message'])) { $request = stripslashes($_REQUEST['message']); if ($_REQUEST['service'] == 'both' || $_REQUEST['service'] == 'twitter') { $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']); $content = $to->OAuthRequest('http://twitter.com/statuses/update.json', array('status' => $request), 'POST'); } if ($_REQUEST['service'] == 'both' || $_REQUEST['service'] == 'facebook') { $facebook_content = facebook_client()->api_client->stream_publish($request); } echo json_encode(array('twitter' => $content, 'facebook' => $facebook_content)); }
break; case 'twitter': if (isset($_GET['lt']) && $_GET['lt'] == 1) { $d_db = sprintf('delete from %s where aid=%s and name=%s', $dbprefix . 'm_sync', $r_dbu['id'], SQLString($nct, 'text')); $result = mysql_query($d_db) or die(''); header('Location:./?m=profile&t=sync&n=' . $nct); exit; } require_once 'lib/twitterOAuth.php'; $is_sync = 0; $s_dby = sprintf('select id, s_id, s_t, s_s, s_n, is_show from %s where aid=%s and name=%s limit 1', $dbprefix . 'm_sync', $r_dbu['id'], SQLString($nct, 'text')); $q_dby = mysql_query($s_dby) or die(''); $r_dby = mysql_fetch_assoc($q_dby); if (mysql_num_rows($q_dby) > 0) { $to = new TwitterOAuth($config['tw_key'], $config['tw_se'], $r_dby['s_t'], $r_dby['s_s']); $ma = $to->OAuthRequest('https://twitter.com/account/verify_credentials.json', array(), 'GET'); if (isset($ma['id']) && $ma['id'] != '') { $is_sync = 1; $d_db = sprintf('delete from %s where aid<>%s and name=%s and s_id=%s', $dbprefix . 'm_sync', $r_dbu['id'], SQLString($nct, 'text'), SQLString($ma['id'], 'text')); $result = mysql_query($d_db) or die(''); if ($r_dby['s_id'] != $ma['id'] || $r_dby['s_n'] != $ma['screen_name']) { $u_db = sprintf('update %s set s_id=%s, s_n=%s where id=%s', $dbprefix . 'm_sync', SQLString($ma['id'], 'text'), SQLString($ma['screen_name'], 'text'), $r_dby['id']); $result = mysql_query($u_db) or die(''); } $content .= '当前已绑定Twitter账号<table width="200"><tr><td align="center">' . ($ma['profile_image_url'] != '' ? '<img src="' . $ma['profile_image_url'] . '" alt=""/><br/>' : '') . '<a href="http://twitter.com/' . $ma['screen_name'] . '" target="_blank">' . $ma['name'] . '</a>(<a href="?m=profile&t=sync&n=' . $nct . '&lt=1">取消绑定</a>)</td></tr></table>'; $content .= '<br/><br/><form method="post" action=""><input type="checkbox" name="isl_tw" value="1"' . ($r_dbu['isl_tw'] > 0 ? ' checked="checked"' : '') . '/>隐藏已绑定Twitter账号相关信息<br/><input type="submit" value="更新" class="button"/><input type="hidden" name="isl_tw_h" value="1"/></form>'; } else { $d_db = sprintf('delete from %s where aid=%s and name=%s', $dbprefix . 'm_sync', $r_dbu['id'], SQLString($nct, 'text')); $result = mysql_query($d_db) or die(''); } }
function check_source($src, $tb_o) { $source_check_result = ''; $log_msg = ''; $is_ok = false; // remove modifiers if (stripos($src, '|') > 1) { $source_check_result = ' ' . $src . ' - <span class="fail">' . __('FAIL', 'tweetblender') . '</span>'; $log_msg = "({$src})" . __('only screen names work with favorites', 'tweetblender') . "\n"; return array($is_ok, $source_check_result, $log_msg); } $source_is_screen_name = false; // if it's a list, report it as bad source if (stripos($src, '@') === 0 && stripos($src, '/') > 1) { $source_check_result = ' ' . $src . ' - <span class="fail">' . __('FAIL', 'tweetblender') . '</span>'; $log_msg = "({$src})" . __('only screen names work with favorites', 'tweetblender') . "\n"; return array($is_ok, $source_check_result, $log_msg); } elseif (stripos($src, '@') === 0) { $api_url = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; $api_params = array('screen_name' => substr($src, 1)); } else { $source_check_result = ' ' . $src . ' - <span class="fail">' . __('FAIL', 'tweetblender') . '</span>'; $log_msg = "({$src})" . __('only screen names work with favorites', 'tweetblender') . "\n"; return array($is_ok, $source_check_result, $log_msg); } // try to get data from Twitter if (isset($tb_o['oauth_access_token'])) { $oAuth = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $tb_o['oauth_access_token']['oauth_token'], $tb_o['oauth_access_token']['oauth_token_secret']); $json_data = $oAuth->OAuthRequest($api_url, 'GET', $api_params); // if we didn't get any data if (!isset($json_data)) { $source_check_result = ' ' . $src . ' - <span class="fail">' . __('FAIL', 'tweetblender') . '</span>'; $log_msg = "({$src}) " . __('json error', 'tweetblender') . ': ' . __('can not get json', 'tweetblender') . "\n" . $apiUrl; } elseif (isset($json_data->{'errors'})) { // if it's just limit error we are OK if (strpos($json_data->{'errors'}->{'message'}, "Rate limit exceeded") === 0) { $is_ok = true; $source_check_result = ' ' . $src . ' - <span class="pass">' . __('OK', 'tweetblender') . '</span>'; $log_msg = "({$src}) " . __('Error', 'tweetblender') . ': ' . __('limit error', 'tweetblender') . "\n"; } else { $source_check_result = ' ' . $src . ' - <span class="fail">' . __('FAIL', 'tweetblender') . '</span>'; $log_msg = "({$src}) " . __('json error', 'tweetblender') . ': ' . $jsonData->{error} . "\n"; } } else { $is_ok = true; $source_check_result = ' ' . $src . ' - <span class="pass">' . __('OK', 'tweetblender') . '</span>'; $log_msg = "({$src}) " . __('Got json with no errors', 'tweetblender') . "\n"; } } else { $source_check_result = ' ' . $src . ':<span class="fail">' . __('FAIL', 'tweetblender') . '</span>'; $log_msg = "({$src})" . __('HTTP error: ', 'tweetblender') . __('no oAuth tokens', 'tweetblender') . "\n"; } return array($is_ok, $source_check_result, $log_msg); }
} } } } mysql_free_result($q_dby); } break; case 'twitter': if ($config['is_tw'] > 0 && $config['tw_key'] != '' && $config['tw_se'] != '') { $s_dby = sprintf('select s_id, s_t, s_s from %s where aid=%s and name=%s and is_show=0 limit 1', $dbprefix . 'm_sync', $id, SQLString('twitter', 'text')); $q_dby = mysql_query($s_dby) or die(''); $r_dby = mysql_fetch_assoc($q_dby); if (mysql_num_rows($q_dby) > 0) { require_once 'lib/twitterOAuth.php'; $to = new TwitterOAuth($config['tw_key'], $config['tw_se'], $r_dby['s_t'], $r_dby['s_s']); $ma = $to->OAuthRequest('https://twitter.com/statuses/user_timeline.json', array('count' => 5, 'user_id' => $r_dby['s_id']), 'GET'); if (is_array($ma) && count($ma) > 0) { foreach ($ma as $v) { if (trim($v['text']) != '') { echo '<div class="sync_list" style="background-image: url(images/i-twitter.gif);">' . trim($v['text']) . '</div>'; } } } } mysql_free_result($q_dby); } break; case 'facebook': if ($config['is_fb'] > 0 && $config['fb_se'] != '' && $config['fb_app_id'] != '') { $s_dby = sprintf('select s_t from %s where aid=%s and name=%s and is_show=0 limit 1', $dbprefix . 'm_sync', $id, SQLString('sina', 'text')); $q_dby = mysql_query($s_dby) or die('');
if ($_SESSION['oauth_access_token'] === NULL && $_SESSION['oauth_access_token_secret'] === NULL) { /* Create TwitterOAuth object with app key/secret and token key/secret from default phase */ $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']); /* Request access tokens from twitter */ $tok = $to->getAccessToken(); /* Save the access tokens. Normally these would be saved in a database for future use. */ $_SESSION['oauth_access_token'] = $tok['oauth_token']; $_SESSION['oauth_access_token_secret'] = $tok['oauth_token_secret']; } /* Random copy */ $content = 'your account should now be registered with twitter. Check here:<br />'; $content .= '<a href="https://twitter.com/account/connections">https://twitter.com/account/connections</a>'; /* Create TwitterOAuth with app key/secret and user access key/secret */ $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']); /* Run request on twitter API as user. */ $content = $to->OAuthRequest('https://twitter.com/account/verify_credentials.xml', array(), 'POST'); //$content = $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => 'Test OAuth update. #testoauth'), 'POST'); //$content = $to->OAuthRequest('https://twitter.com/statuses/replies.xml', array(), 'POST'); break; } /*}}}*/ ?> <html> <head> <title>Twitter OAuth in PHP</title> </head> <body> <h2>Welcome to a Twitter OAuth PHP example.</h2> <p>This site is a basic showcase of Twitters new OAuth authentication method. Everything is saved in sessions. If you want to start over <a href='<?php echo $_SERVER['PHP_SELF'];
/** * Name: updateStatus * descrition : update twitter status . * called from : dashboard * return : status message to dashbaord. */ function updateStatus() { if ($this->data) { $mmm_id = $this->Session->read('id'); $band_id = $this->data['Dashboard']['bandid']; if (!empty($this->data['Dashboard']['twt']) == "on") { $twtResult = $this->Twtuser->find(array('mmm_id' => $mmm_id, 'band_id' => $band_id, 'status' => 1)); if ($twtResult) { $result = $this->Twitter->find(array('user_id' => $twtResult['Twtuser']['user_id'])); if ($result) { if ($this->Session->check('oauth_request_token')) { $this->Session->del('oauth_request_token'); } if ($this->Session->check('oauth_request_token_secret')) { $this->Session->del('oauth_request_token_secret'); } if ($this->Session->check('oauth_access_token')) { $this->Session->del('oauth_access_token'); } if ($this->Session->check('oauth_access_token_secret')) { $this->Session->del('oauth_access_token_secret'); } $request_token = $result['Twitter']['request_token']; $token_secret = $result['Twitter']['token_secret']; $access_token = $result['Twitter']['access_token']; $access_secret = $result['Twitter']['access_secret']; $this->Session->write('oauth_request_token', $request_token); $this->Session->write('oauth_request_token_secret', $token_secret); $this->Session->write('oauth_state', 'returned'); $this->Session->write('oauth_access_token', $access_token); $this->Session->write('oauth_access_token_secret', $access_secret); // Create TwitterOAuth with app key/secret and user access key/secret $to = new TwitterOAuth($this->consumer_key, $this->consumer_secret, $access_token, $access_secret); sleep(2); $status = $this->data['Dashboard']['status']; $xcontent = $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => $status), 'POST'); sleep(2); if ($xcontent) { $result['Twitter']['tweets'] = $status; $this->Twitter->save($result); echo "Twitter status updated succesfully <br>"; } else { echo "Unable to update Twitter status . Try again."; } //$this->redirect("/dashboard/index/?bandid=".$band_id); exit; } } } // if($this->data['Dashboard']['twt']=="on") } exit; }
public static function postToTwitter($api) { if (Typecho_Cookie::get('oauth_access_token') && Typecho_Cookie::get('oauth_access_token_secret') && $api->request->post_to_twitter) { $options = Typecho_Widget::widget('Widget_Options'); $config = $options->plugin('ConnectToTwitter'); $to = new TwitterOAuth($config->consumerKey, $config->consumerSecret, Typecho_Cookie::get('oauth_access_token'), Typecho_Cookie::get('oauth_access_token_secret')); $url_array = array(); $url_array = explode('?', $api->request->getReferer()); $url = $url_array[0] . '#comment-' . $api->coid; $post = $api->text . ' ( from ' . $url . ' ) '; $twitter = $to->OAuthRequest('https://twitter.com/statuses/update.xml', array('status' => $post), 'POST'); } return $comment; }
function check_source($src, $tb_o) { global $json; $need_oauth = false; $is_private = false; $source_check_result = ''; $log_msg = ''; $is_ok = false; // remove private account markup if (stripos($src, '!') === 0) { $src = substr($src, 1); } // remove modifiers if (stripos($src, '|') > 1) { $source_check_result = ' ' . $src . ' - <span class="fail">FAIL</span>'; $log_msg = "({$src}) only screen names work with favorites\n"; return array($is_ok, $is_private, $need_oauth, $source_check_result, $log_msg); } $source_is_screen_name = false; // if it's a list, report it as bad source if (stripos($src, '@') === 0 && stripos($src, '/') > 1) { $source_check_result = ' ' . $src . ' - <span class="fail">FAIL</span>'; $log_msg = "({$src}) only screen names work with favorites\n"; return array($is_ok, $is_private, $need_oauth, $source_check_result, $log_msg); } elseif (stripos($src, '@') === 0) { $source_is_screen_name = true; $apiUrl = 'http://api.twitter.com/1/favorites/' . substr($src, 1) . '.json'; } else { $source_check_result = ' ' . $src . ' - <span class="fail">FAIL</span>'; $log_msg = "({$src}) only screen names work with favorites\n"; return array($is_ok, $is_private, $need_oauth, $source_check_result, $log_msg); } if (!class_exists('WP_Http')) { include_once ABSPATH . WPINC . '/class-http.php'; } $http = new WP_Http(); $result = $http->request($apiUrl); // try to get data from Twitter if (!is_wp_error($result)) { $jsonData = $json->decode($result['body']); // if Twitter reported error if ($jsonData->{error}) { // if it's a private user if (strpos($jsonData->{error}, "Not authorized") !== false) { $is_private = true; // if we don't have access tokens - error if (!array_key_exists('oauth_access_token', $tb_o)) { $source_check_result = $src . ' - <span class="fail">PRIVATE</span>'; $log_msg = "({$src}) Private: needs oAuth\n"; $need_oauth = true; } else { $is_ok = true; $source_check_result = ' ' . $src . ' - <span class="pass">PRIVATE</span>'; $log_msg = "({$src}) Private: we have oAuth\n"; } } elseif (strpos($jsonData->{error}, "Rate limit exceeded") === 0) { $is_ok = true; $source_check_result = ' ' . $src . ' - <span class="pass">OK</span>'; $log_msg = "({$src}) Error: limit error\n"; } else { $source_check_result = ' ' . $src . ' - <span class="fail">FAIL</span>'; $log_msg = "({$src}) json error: " . $jsonData->{error} . "\n"; } } else { $is_ok = true; $source_check_result = ' ' . $src . ' - <span class="pass">OK</span>'; $log_msg = "({$src}) Got json with no errors\n"; } } else { // if it's a protected source if ($source_is_screen_name && $result['response']['code'] == 401) { $is_private = true; // if have tokens - try to get it if ($tb_o['oauth_user_access_key'] && $tb_o['oauth_user_access_secret']) { if (!$oAuth) { $oAuth = new TwitterOAuth($tb_o['oauth_consumer_key'], $tb_o['oauth_consumer_secret'], $tb_o['oauth_user_access_key'], $tb_o['oauth_user_access_secret']); } $content = $oAuth->OAuthRequest('https://api.twitter.com/1/favorites/' . substr($src, 1) . 'search.json', array(), 'GET'); } else { $need_oauth = true; $source_check_result = ' ' . $src . ' - <span class="fail">PRIVATE</span>'; $log_msg = "({$src}) Private: needs oAuth\n"; } } else { $source_check_result = ' ' . $src . ':<span class="fail">FAIL</span>'; $log_msg = "({$src}) HTTP error: " . $result->get_error_message() . "\n"; } } return array($is_ok, $is_private, $need_oauth, $source_check_result, $log_msg); }
} switch ($state) { case 'returned': if (!isset($_SESSION['oauth']['oauth_access_token']) && !isset($_SESSION['oauth']['oauth_access_token_secret'])) { /* Create TwitterOAuth object with app key/secret and token key/secret from default phase */ $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth']['oauth_request_token'], $_SESSION['oauth']['oauth_request_token_secret']); /* Request access tokens from twitter */ $tok = $to->getAccessToken(); /* Save the access tokens. Normally these would be saved in a database for future use. */ $_SESSION['oauth']['oauth_access_token'] = $tok['oauth_token']; $_SESSION['oauth']['oauth_access_token_secret'] = $tok['oauth_token_secret']; } //echo "whoa - it got returned!"; $to = new TwitterOAuth($consumer_key, $consumer_secret, $_SESSION['oauth']['oauth_access_token'], $_SESSION['oauth']['oauth_access_token_secret']); /* Run request on twitter API as user. */ $content = json_decode($to->OAuthRequest('https://twitter.com/account/verify_credentials.json', array(), 'GET')); //var_dump( $content ); //register the panel in the normal way require_once dirname(__FILE__) . "/../structs.php"; require_once dirname(__FILE__) . "/../twitter_tools.php"; $panel_id = $content->screen_name; $panel_user = $content->screen_name; $panel_pass = '******'; $new_panel = new Panel(); $new_panel->user = $panel_user; $new_panel->pass = $panel_pass; $new_panel->id = $panel_id; $new_panel->oauth = $to; $new_panel->gen_info = json_decode(get_twitter_user_info($panel_user)); //need to check user credentials //$legit_user = check_twitter_user($panel_user,$panel_pass);
$twObj = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauthToken'], $_SESSION['oauthTokenSecret']); // 検索する文字を変数に入れる。複数の場合は[AND]を使う $andkey = htmlspecialchars($_GET['text']); if (preg_match("/ | /", $andkey)) { //print_r(preg_split("/ | /", $andkey)); $andkey_justice = preg_split("/ | /", $andkey); } else { $andkey_justice = array($andkey); } // クエリーオプション $options = array('q' => $andkey . " -rt -bot source:Twitter_for_iPhone", 'count' => '100', 'lang' => 'ja', 'result_type' => 'mix'); // クエリーオプション2つめ $options3 = array('q' => $andkey . " -rt -bot source:Twitter_for_android", 'count' => '100', 'lang' => 'ja', 'result_type' => 'mix'); // レートリミット クエリーオプション $options2 = array("resources" => "search,statuses"); $json = $twObj->OAuthRequest('https://api.twitter.com/1.1/search/tweets.json', 'GET', $options); $json3 = $twObj->OAuthRequest('https://api.twitter.com/1.1/search/tweets.json', 'GET', $options3); $json2 = $twObj->OAuthRequest("https://api.twitter.com/1.1/application/rate_limit_status.json", 'GET', $options2); $jset = json_decode($json, true); $jset3 = json_decode($json3, true); $jset2 = json_decode($json2, true); //print_r($jset2["resources"]); $list = array(); $time_line_texts = array(); $completion_data = array("name" => "tagcloud", "children" => array()); if ($jset2["resources"]["statuses"]["/statuses/user_timeline"]["remaining"] > 10) { foreach ($jset2 as $result2) { $str = $result2["statuses"]["/statuses/user_timeline"]["remaining"]; $sh = $result2["search"]["/search/tweets"]["remaining"]; //echo "timeline:".$str."<br>search:".$sh; }