当前位置: 首页>>代码示例>>PHP>>正文


PHP TwitterOAuth::OAuthRequest方法代码示例

本文整理汇总了PHP中TwitterOAuth::OAuthRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP TwitterOAuth::OAuthRequest方法的具体用法?PHP TwitterOAuth::OAuthRequest怎么用?PHP TwitterOAuth::OAuthRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TwitterOAuth的用法示例。


在下文中一共展示了TwitterOAuth::OAuthRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: post_twitt_news

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;
    }
}
开发者ID:shiooooooookun,项目名称:Nouweo_PHP,代码行数:31,代码来源:post_twitt_news.php

示例2: twitter_oauth_login_test

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;
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:29,代码来源:ak_twitter.php

示例3: tweet

 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));
 }
开发者ID:ktanifuji,项目名称:gr3,代码行数:10,代码来源:ControllerBase.php

示例4: getTweets

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);
}
开发者ID:xkeitax48,项目名称:mySamples,代码行数:11,代码来源:forTwitterApi.php

示例5: twitterApi

 /**
  * 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);
 }
开发者ID:kurari,项目名称:Nyaa-System,代码行数:15,代码来源:twitter.class.php

示例6: get

 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;
 }
开发者ID:hellogerard,项目名称:twitter-roll,代码行数:13,代码来源:twitter_roll.php

示例7: TweetSearchGet

 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;
     }
 }
开发者ID:NsProject,项目名称:NicoSubLine-OPNE-,代码行数:47,代码来源:nicotwitterclass.php

示例8: handleTwitterAuthentication

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;
    }
}
开发者ID:kohlhofer,项目名称:Mindmeto,代码行数:47,代码来源:helper.php

示例9: _tweet

 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));
 }
开发者ID:buiteke,项目名称:ToDo,代码行数:18,代码来源:AppController.php

示例10: send_to_twitter

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);
    }
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:44,代码来源:twitter.php

示例11: 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;
 }
开发者ID:nathanlon,项目名称:twical,代码行数:24,代码来源:sfTwitterAPI.php

示例12: PostCheck

$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;
开发者ID:nobuhiko,项目名称:flickrtotwitter,代码行数:31,代码来源:index.php

示例13: TwitterOAuth

 }
 // 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)) {
开发者ID:hacklabr,项目名称:toquenobrasil,代码行数:31,代码来源:ws.php

示例14: verifyCredentials

 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;
 }
开发者ID:nmeierpolys,项目名称:TweetSampler,代码行数:8,代码来源:twitterphp.php

示例15: TwitterOAuth

}
// アプリ登録した際に発行された値を入れて下さい。
$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'];
开发者ID:orangelily1127,项目名称:LocationInformationService,代码行数:31,代码来源:api3.php


注:本文中的TwitterOAuth::OAuthRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。