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


PHP tmhOAuth::request方法代码示例

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


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

示例1: login

 /**
  * Login to facebook and get the associated cloudrexx user.
  */
 public function login()
 {
     // fixing timestamp issue with twitter
     // it is necessary that the twitter server has the same time as our system
     date_default_timezone_set('UTC');
     $tmhOAuth = new \tmhOAuth(array('consumer_key' => $this->applicationData[0], 'consumer_secret' => $this->applicationData[1]));
     // set the timestamp
     $tmhOAuth->config['force_timestamp'] = true;
     $tmhOAuth->config['timestamp'] = time();
     if (isset($_GET['oauth_verifier'])) {
         $tmhOAuth->config['user_token'] = $_SESSION['oauth']['oauth_token'];
         $tmhOAuth->config['user_secret'] = $_SESSION['oauth']['oauth_token_secret'];
         $tmhOAuth->request('POST', $tmhOAuth->url('oauth/access_token', ''), array('oauth_verifier' => $_GET['oauth_verifier'], 'x_auth_access_type' => 'read'));
         $access_token = $tmhOAuth->extract_params($tmhOAuth->response['response']);
         $tmhOAuth->config['user_token'] = $access_token['oauth_token'];
         $tmhOAuth->config['user_secret'] = $access_token['oauth_token_secret'];
         $tmhOAuth->request('GET', $tmhOAuth->url('1.1/account/verify_credentials'));
         $resp = json_decode($tmhOAuth->response['response']);
         unset($_SESSION['oauth']);
         $name = explode(' ', $resp->name);
         self::$userdata = array('first_name' => $name[0], 'last_name' => $name[1], 'email' => $resp->screen_name . '@twitter.com');
         $this->getContrexxUser($resp->id);
     } else {
         $tmhOAuth->request('POST', $tmhOAuth->url('oauth/request_token', ""), array('oauth_callback' => \Cx\Lib\SocialLogin::getLoginUrl(self::OAUTH_PROVIDER)));
         $_SESSION['oauth'] = $tmhOAuth->extract_params($tmhOAuth->response['response']);
         $url = 'https://api.twitter.com/oauth/authenticate?oauth_token=' . $_SESSION['oauth']['oauth_token'];
         \Cx\Core\Csrf\Controller\Csrf::header("Location: " . $url);
         exit;
     }
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:33,代码来源:Twitter.class.php

示例2: nextend_api_auth_flow

function nextend_api_auth_flow()
{
    $api_key = NextendRequest::getVar('api_key');
    $api_secret = NextendRequest::getVar('api_secret');
    $redirect_uri = NextendRequest::getVar('redirect_uri');
    if (session_id() == "") {
        @session_start();
    }
    if (!$api_key || !$api_secret || !$redirect_uri) {
        $api_key = isset($_SESSION['api_key']) ? $_SESSION['api_key'] : null;
        $api_secret = isset($_SESSION['api_secret']) ? $_SESSION['api_secret'] : null;
        $redirect_uri = isset($_SESSION['redirect_uri']) ? $_SESSION['redirect_uri'] : null;
    } else {
        $_SESSION['api_key'] = $api_key;
        $_SESSION['api_secret'] = $api_secret;
        $_SESSION['redirect_uri'] = $redirect_uri;
    }
    if ($api_key && $api_secret) {
        require_once dirname(__FILE__) . "/api/tmhOAuth.php";
        $tmhOAuth = new tmhOAuth(array('consumer_key' => $api_key, 'consumer_secret' => $api_secret));
        if (isset($_REQUEST['oauth_verifier'])) {
            $tmhOAuth->config['user_token'] = $_SESSION['t_oauth']['oauth_token'];
            $tmhOAuth->config['user_secret'] = $_SESSION['t_oauth']['oauth_token_secret'];
            $code = $tmhOAuth->request('POST', $tmhOAuth->url('oauth/access_token', ''), array('oauth_verifier' => $_REQUEST['oauth_verifier']));
            if ($code == 200) {
                $access_token = $tmhOAuth->extract_params($tmhOAuth->response['response']);
                unset($_SESSION['api_key']);
                unset($_SESSION['api_secret']);
                unset($_SESSION['redirect_uri']);
                unset($_SESSION['t_oauth']);
                echo '<script type="text/javascript">';
                echo 'window.opener.setToken("' . $access_token['oauth_token'] . '", "' . $access_token['oauth_token_secret'] . '");';
                echo '</script>';
            } else {
                echo '<h3>Error</h3><br />';
                echo $tmhOAuth->response['response'];
                exit;
            }
        } else {
            $code = $tmhOAuth->request('POST', $tmhOAuth->url('oauth/request_token', ''), array('oauth_callback' => $redirect_uri));
            if ($code == 200) {
                $oauth = $tmhOAuth->extract_params($tmhOAuth->response['response']);
                $_SESSION['t_oauth'] = $oauth;
                $authurl = $tmhOAuth->url("oauth/authenticate", '') . "?oauth_token=" . $oauth['oauth_token'] . "&force_login=1";
                header('Location: ' . $authurl);
                exit;
            } else {
                echo '<h3>Error</h3><br />';
                echo $tmhOAuth->response['response'];
                exit;
            }
        }
    }
}
开发者ID:macconsultinggroup,项目名称:WordPress,代码行数:54,代码来源:auth.php

示例3: LatestTweetsList

 public function LatestTweetsList($limit = '5')
 {
     $conf = SiteConfig::current_site_config();
     if (empty($conf->TwitterName) || empty($conf->TwitterConsumerKey) || empty($conf->TwitterConsumerSecret) || empty($conf->TwitterAccessToken) || empty($conf->TwitterAccessTokenSecret)) {
         return new ArrayList();
     }
     $cache = SS_Cache::factory('LatestTweets_cache');
     if (!($results = unserialize($cache->load(__FUNCTION__)))) {
         $results = new ArrayList();
         require_once dirname(__FILE__) . '/tmhOAuth/tmhOAuth.php';
         require_once dirname(__FILE__) . '/tmhOAuth/tmhUtilities.php';
         $tmhOAuth = new tmhOAuth(array('consumer_key' => $conf->TwitterConsumerKey, 'consumer_secret' => $conf->TwitterConsumerSecret, 'user_token' => $conf->TwitterAccessToken, 'user_secret' => $conf->TwitterAccessTokenSecret, 'curl_ssl_verifypeer' => false));
         $code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array('screen_name' => $conf->TwitterName, 'count' => $limit));
         $tweets = $tmhOAuth->response['response'];
         $json = new JSONDataFormatter();
         if (($arr = $json->convertStringToArray($tweets)) && is_array($arr) && isset($arr[0]['text'])) {
             foreach ($arr as $tweet) {
                 try {
                     $here = new DateTime(SS_Datetime::now()->getValue());
                     $there = new DateTime($tweet['created_at']);
                     $there->setTimezone($here->getTimezone());
                     $date = $there->Format('Y-m-d H:i:s');
                 } catch (Exception $e) {
                     $date = 0;
                 }
                 $results->push(new ArrayData(array('Text' => nl2br(tmhUtilities::entify_with_options($tweet, array('target' => '_blank'))), 'Date' => SS_Datetime::create_field('SS_Datetime', $date))));
             }
         }
         $cache->save(serialize($results), __FUNCTION__);
     }
     return $results;
 }
开发者ID:unisolutions,项目名称:silverstripe-latesttweets,代码行数:32,代码来源:LaTw_Page_Controller_Extension.php

示例4: sendToSocialMedia

 /**
  *
  * @param array $data
  * @param array $services
  */
 public function sendToSocialMedia(array $data, array $services = array('facebook', 'twitter'))
 {
     // init output
     $ids = array('facebook' => null, 'twitter' => null);
     // Facebook
     if (in_array('facebook', $services) && $this->confirmFacebookAccess()) {
         $facebook = new Facebook(array('appId' => static::$conf->FacebookAppId, 'secret' => static::$conf->FacebookAppSecret));
         $facebook->setAccessToken(static::$conf->FacebookPageAccessToken);
         try {
             $post_id = $facebook->api("/" . static::$conf->FacebookPageId . "/feed", "post", $data);
             $ids['facebook'] = $post_id['id'];
         } catch (FacebookApiException $e) {
             SS_Log::log('Error ' . $e->getCode() . ' : ' . $e->getFile() . ' Line ' . $e->getLine() . ' : ' . $e->getMessage() . "\n" . 'BackTrace: ' . "\n" . $e->getTraceAsString(), SS_Log::ERR);
         }
     }
     // Twitter
     if (in_array('twitter', $services) && $this->confirmTwitterAccess()) {
         $connection = new tmhOAuth(array('consumer_key' => static::$conf->TwitterConsumerKey, 'consumer_secret' => static::$conf->TwitterConsumerSecret, 'user_token' => static::$conf->TwitterOAuthToken, 'user_secret' => static::$conf->TwitterOAuthSecret));
         $tweet = $data['name'] . ": " . $data['link'];
         $code = $connection->request('POST', $connection->url('1.1/statuses/update'), array('status' => $tweet));
         if ($code == 200) {
             $data = json_decode($connection->response['response']);
             $ids['twitter'] = $data->id_str;
         }
     }
     return $ids;
 }
开发者ID:helpfulrobot,项目名称:azt3k-abc-silverstripe-social,代码行数:32,代码来源:PostToSocialMedia.php

示例5: getTweet

/**
* This method uses the Twitter API to get specified amount of Tweet Responses
* from Twitter for a specified Twitter User.
*
* @param screenName :: The Twitter Handle for which we require the tweets
* @param count :: The number of recent tweets needed for the Twitter User
*
* @return response :: Array of Twitter Response Objects
*/
function getTweet($screenName, $count)
{
    $parameters = array();
    $parameters['screen_name'] = $screenName;
    $parameters['count'] = $count;
    $connection = new tmhOAuth(array('consumer_key' => 'C8U6aOYWFkfuPxOiFBxoF87jF', 'consumer_secret' => 'cODzOUcJSqd3ATG15J25GXZlz7AyhK6gHbRCmsCiMIn0rfMKIu', 'user_token' => '2261472366-CPKf4pZ9fosiZ2zCQfXi7tiexIzbiNfzJ8lEcoC', 'user_secret' => 'gH6qWAAOCrmS38sf5ipaXIxHZHLHNGtYOmCZcJrFli0M9'));
    $twitterPath = '1.1/statuses/user_timeline.json';
    $http_code = $connection->request('GET', $connection->url($twitterPath), $parameters);
    // If everything is good
    if ($http_code === 200) {
        $response = strip_tags($connection->response['response']);
        $twitterResp = json_decode($response, true);
        // Log Success
        if (count($twitterResp) == 200) {
            logSuccess('tweetylogs.txt', 'Grabbed 200 Tweets for ' . $screenName . ' from the Twitter API.');
            logSuccess('success.txt', 'Grabbed 200 Tweets for ' . $screenName . ' from the Twitter API.');
            logSuccess('tweetylogs.html', 'Grabbed <b>200</b> Tweets for <b>' . $screenName . '</b> from the Twitter API.');
        } else {
            logWarning('tweetylogs.txt', 'Grabbed ' . (string) count($twitterResp) . ' Tweets for' . $screenName . ' from the Twitter API.');
            logWarning('warning.txt', 'Grabbed ' . (string) count($twitterResp) . ' Tweets for' . $screenName . ' from the Twitter API.');
            logWarning('tweetylogs.html', 'Grabbed <b>' . (string) count($twitterResp) . '</b> Tweets for <b>' . $screenName . '</b> from the Twitter API.');
        }
        return $twitterResp;
    } else {
        logError('tweetylogs.txt', 'Error in the function refreshData.php/getTweet() for Twitter User: ' . $screenName . '. HTTP Code not 200. HTTP Code/Error ID: ' . $http_code . '. Error: ' . $connection->response['error']);
        logError('error.txt', 'Error in the function refreshData.php/getTweet() for Twitter User: ' . $screenName . '. HTTP Code not 200. HTTP Code/Error ID: ' . $http_code . '. Error: ' . $connection->response['error']);
        logError('tweetylogs.html', 'Error in the function refreshData.php/getTweet() for Twitter User: <b>' . $screenName . '</b>. HTTP Code not 200. <b>HTTP Code/Error ID:</b> ' . $http_code . '. <b>Error:</b> ' . $connection->response['error']);
    }
}
开发者ID:vreddi,项目名称:twitterGame,代码行数:38,代码来源:refreshData.php

示例6: isAccessTokenValid

 /**
  * Checks if the authentication credentials currently stored in hydra.yml are correct or not.
  *
  * @return boolean
  */
 public function isAccessTokenValid()
 {
     if (empty($this->authentication['accessToken'])) {
         return false;
     }
     $this->api->request('GET', $this->api->url('v1/users/self/feed'), array('access_token' => $this->authentication['accessToken']));
     // HTTP 200 means we were successful
     return $this->api->response['code'] == 200;
 }
开发者ID:beecms,项目名称:virtual-identity,代码行数:14,代码来源:InstagramService.php

示例7: get_twitter_timeline

function get_twitter_timeline($user)
{
    //global $user;
    $tmhOAuth = new tmhOAuth(array('consumer_key' => CONSUMER_KEY, 'consumer_secret' => CONSUMER_SECRET, 'token' => USER_TOKEN, 'secret' => USER_SECRET));
    if ($tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline.json'), array('include_entities' => 'false', 'include_rts' => 'false', 'trim_user' => 'true', 'screen_name' => $user, 'exclude_replies' => 'false', 'count' => TL_COUNT), true) != 200) {
        header("Content-Type: text/html; charset=utf-8");
        die('Could not connect to Twitter');
    }
    return json_decode($tmhOAuth->response['response'], true);
}
开发者ID:puteulanus,项目名称:smzdm_monitor,代码行数:10,代码来源:function.inc.php

示例8: tweetFromCoffeeMachine

function tweetFromCoffeeMachine($message)
{
    $tmhOAuth = new tmhOAuth(array('consumer_key' => 'yBqPMCfmM59Rbglvz1Ulaw', 'consumer_secret' => 'emXtf7PDoYURANce1RqRE2FaZpgJeaQixRlCafpQ0', 'user_token' => '576073937-gZokaOQgJwY3U64frIV1MkzHfnelx3XvxMC2FHOM', 'user_secret' => 'ursK27EZa2nZliVBBFdfEjpiTwMkqdQoqpnTZG07Sgc'));
    $code = $tmhOAuth->request('POST', $tmhOAuth->url('1/statuses/update'), array('status' => $message));
    /* don't care about the response in this case
    	if ($code == 200) {
    	  tmhUtilities::pr(json_decode($tmhOAuth->response['response']));
    	} else {
    	  tmhUtilities::pr($tmhOAuth->response['response']);
    	}*/
}
开发者ID:newtonsheesha,项目名称:RFIDCheckinSystem,代码行数:11,代码来源:tweet.php

示例9: getAccessToken

 /**
  * Returns an array with the permanent access token and access secret
  *
  * @param  string $code the verification code receivied from authorization request
  * @return array        the keys of the returned array are accessToken
  */
 public function getAccessToken($code, $callBackUrl)
 {
     // send request for an access token
     $status = $this->api->request('POST', 'https://accounts.google.com/o/oauth2/token', array('client_id' => $this->authentication['consumer_key'], 'client_secret' => $this->authentication['consumer_secret'], 'grant_type' => 'authorization_code', 'redirect_uri' => $callBackUrl, 'code' => $code));
     if ($status == 200) {
         // get the access token and store it in a cookie
         $response = json_decode($this->api->response['response'], true);
         $return = array('accessToken' => $response['access_token'], 'refreshToken' => $response['refresh_token'], 'expiresIn' => $response['expires_in']);
         return $return;
     }
     throw new ApiException('Obtaining the access token did not work! Status code: ' . $status . '. Response was: ' . $this->api->response['response']);
 }
开发者ID:beecms,项目名称:virtual-identity,代码行数:18,代码来源:YoutubeService.php

示例10: checkTwitter

function checkTwitter($username)
{
    require_once 'libs/Twitter/tmhOAuth-master/tmhOAuth.php';
    require_once 'libs/Twitter/tmhOAuth-master/tmhUtilities.php';
    $tmhOAuth = new tmhOAuth(array('consumer_key' => TWITTER_CONSUMER_KEY, 'consumer_secret' => TWITTER_CONSUMER_SECRET, 'user_token' => TWITTER_USER_TOKEN, 'user_secret' => TWITTER_USER_SECRET));
    $code = $tmhOAuth->request('GET', 'https://api.twitter.com/1.1/users/lookup.json', array('screen_name' => $username));
    if ($code == 200) {
        return json_decode($tmhOAuth->response['response'], true);
    } else {
        return false;
    }
}
开发者ID:emkorybski,项目名称:websummit15-hack,代码行数:12,代码来源:Twitter_update.php

示例11: tfuse_get_tweets

function tfuse_get_tweets($username, $count = 20)
{
    $tweets_cache_path = get_template_directory() . '/cache/twitter_json_' . $username . '_rpp_' . $count . '.cache';
    if (file_exists($tweets_cache_path)) {
        $tweets_cache_timer = intval((time() - filemtime($tweets_cache_path)) / 60);
    } else {
        $tweets_cache_timer = 0;
    }
    if ((!file_exists($tweets_cache_path) or $tweets_cache_timer > 15) && function_exists('curl_init')) {
        require_once dirname(__FILE__) . '/libs/twitter/tmhOAuth.php';
        require_once dirname(__FILE__) . '/libs/twitter/tmhUtilities.php';
        $tmhOAuth = new tmhOAuth(array('consumer_key' => tfuse_options('twitter_consumer_key', ''), 'consumer_secret' => tfuse_options('twitter_consumer_secret', ''), 'user_token' => tfuse_options('twitter_user_token', ''), 'user_secret' => tfuse_options('twitter_user_secret', '')));
        $code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array('screen_name' => $username));
        $response = $tmhOAuth->response;
        $JsonTweets = json_decode($response['response']);
        if (is_array($JsonTweets)) {
            $JsonTweets = array_slice($JsonTweets, 0, $count);
            foreach ($JsonTweets as $JsonKey => $JsonVal) {
                // Some reformatting
                $pattern = array('/[^(:\\/\\/)](www\\.[^ \\n\\r]+)/', '/(https?:\\/\\/[^ \\n\\r]+)/', '/@(\\w+)/', '/^' . $username . ':\\s*/i');
                $replace = array('<a href="http://$1" rel="nofollow"  target="_blank">$1</a>', '<a href="$1" rel="nofollow" target="_blank">$1</a>', '<a href="http://twitter.com/$1" rel="nofollow"  target="_blank">@$1</a>' . '');
                $JsonTweets[$JsonKey]->text = preg_replace($pattern, $replace, $JsonTweets[$JsonKey]->text);
                $JsonTweets[$JsonKey]->created_at = tfuse_since($JsonTweets[$JsonKey]->created_at);
            }
        } else {
            return array();
        }
        // Some error? Return an empty array
        // You may want to extend this to know the exact error
        echo curl_error($curl_handle);
        // or know the http status
        echo curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
        if (file_exists($tweets_cache_path)) {
            unlink($tweets_cache_path);
        }
        $myFile = $tweets_cache_path;
        $fh = fopen($myFile, 'w') or die("can't open file");
        $stringData = json_encode($JsonTweets);
        fwrite($fh, $stringData);
        fclose($fh);
    } else {
        error_reporting(0);
        $file = file_get_contents($tweets_cache_path, true);
        if (!empty($file)) {
            $JsonTweets = json_decode($file);
            if (!is_array($JsonTweets)) {
                $JsonTweets = array();
            }
        }
    }
    return $JsonTweets;
}
开发者ID:pinchpointer,项目名称:ppsitewordpress,代码行数:52,代码来源:GENERAL.php

示例12: call

 /**
  * Call API
  * 
  * @param  string $method
  * @param  string $uri
  * @param  array $params
  * @param  string $fmt
  * @return array
  * @throws \FuelException
  */
 protected function call($method, $uri, $params, $fmt)
 {
     $code = $this->tmhoauth->request($method, $this->tmhoauth->url($uri, $fmt), $params);
     if ($code != 200) {
         throw new \FuelException('Code:' . $code . ' Response:' . $this->tmhoauth->response['response']);
     }
     switch ($fmt) {
         case 'json':
             return json_decode($this->tmhoauth->response['response']);
         default:
             return $this->tmhoauth->extract_params($this->tmhoauth->response['response']);
     }
 }
开发者ID:mp-php,项目名称:fuel-packages-twitter,代码行数:23,代码来源:twitter.php

示例13: getTweets

 protected function getTweets($number)
 {
     $items = array();
     $twitter = new tmhOAuth(array('consumer_key' => TWITTER_CONSUMER_KEY, 'consumer_secret' => TWITTER_CONSUMER_SECRET, 'user_token' => TWITTER_USER_TOKEN, 'user_secret' => TWITTER_USER_SECRET));
     $responseCode = $twitter->request('GET', $twitter->url('1/statuses/home_timeline'), array('count' => $number, 'contributor_details' => true));
     if (200 == $responseCode) {
         $tweets = json_decode($twitter->response['response']);
         foreach ($tweets as $tweet) {
             $items[] = $this->makeBalloonFromTweet($tweet);
         }
     }
     return $items;
 }
开发者ID:xaznblade,项目名称:hwkinect,代码行数:13,代码来源:api.php

示例14: widget

    /** @see WP_Widget::widget */
    function widget($args, $instance)
    {
        extract($args);
        //these are our widget options
        $title = isset($instance['title']) ? $instance['title'] : "";
        $animation = isset($instance['animation']) ? $instance['animation'] : "";
        $login = isset($instance['login']) ? $instance['login'] : "";
        $count = isset($instance['count']) ? $instance['count'] : "";
        $consumer_key = isset($instance['consumer_key']) ? $instance['consumer_key'] : "";
        $consumer_secret = isset($instance['consumer_secret']) ? $instance['consumer_secret'] : "";
        $access_token = isset($instance['access_token']) ? $instance['access_token'] : "";
        $access_token_secret = isset($instance['access_token_secret']) ? $instance['access_token_secret'] : "";
        echo $before_widget;
        require_once locate_template("/libraries/tmhOAuth/tmhOAuth.php");
        require_once locate_template("/libraries/tmhOAuth/tmhUtilities.php");
        $tmhOAuth = new tmhOAuth(array('consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'user_token' => $access_token, 'user_secret' => $access_token_secret));
        $code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array('screen_name' => $login, 'count' => $count, 'include_rts' => 'true'));
        $response = $tmhOAuth->response;
        ?>
		<div class="clearfix">
			<div class="header_left">
				<?php 
        if ($title) {
            echo ((int) $animation ? str_replace("box_header", "box_header animation-slide", $before_title) : str_replace("animation-slide", "", $before_title)) . apply_filters("widget_title", $title) . $after_title;
        }
        ?>
			</div>
			<div class="header_right">
				<a href="#" id="latest_tweets_prev" class="scrolling_list_control_left icon_small_arrow left_white"></a>
				<a href="#" id="latest_tweets_next" class="scrolling_list_control_right icon_small_arrow right_white"></a>
			</div>
		</div>
		<div class="scrolling_list_wrapper">
			<ul class="scrolling_list latest_tweets">
				<?php 
        //				require_once(get_template_directory() . "/libraries/lib_autolink.php");
        require_once locate_template("/libraries/lib_autolink.php");
        $tweets = json_decode($response['response']);
        if (count($tweets->errors)) {
            echo '<li class="icon_small_arrow right_white"><p>' . $tweets->errors[0]->message . '! ' . __('Please check your config under Appearance->Widgets->Twitter Feed!', 'medicenter') . '</p></li>';
        } else {
            foreach ($tweets as $tweet) {
                echo '<li class="icon_small_arrow right_white"><p>' . autolink($tweet->text, 20, ' target="_blank"') . '<abbr title="' . date('c', strtotime($tweet->created_at)) . '" class="timeago">' . $tweet->created_at . '</abbr></p></li>';
            }
        }
        ?>
			</ul>
		</div>
		<?php 
        echo $after_widget;
    }
开发者ID:farkbarn,项目名称:hcudamp,代码行数:52,代码来源:widget-twitter.php

示例15: getAction

 public function getAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     header('Content-type: application/json');
     /* Set locale to Dutch */
     setlocale(LC_ALL, 'nl_NL');
     $cacheId = 'Mobile_Twitter';
     $cache = Zend_Registry::get('cache');
     if (true == ($result = $cache->load($cacheId))) {
         if ($result->timestamp + 240 < time()) {
             // vernieuwen om de 4 minuten oftewel 240 seconden
             $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('Twitter_Webservice'));
         }
         $output = $result->output;
         if ($this->_getParam('version', '1') == '2') {
             foreach ($output as $key => $tweet) {
                 $output[$key]['text'] = $this->processLinks($tweet['text']);
             }
         }
     } else {
         $config = Zend_Registry::get('config');
         require APPLICATION_ROOT . '/library/Twitter/tmhOAuth.php';
         require APPLICATION_ROOT . '/library/Twitter/tmhUtilities.php';
         $tmhOAuth = new tmhOAuth(array('consumer_key' => $config->twitter->customer_key, 'consumer_secret' => $config->twitter->customer_secret, 'user_token' => $config->twitter->user_token, 'user_secret' => $config->twitter->user_secret, 'debug' => false));
         $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array('screen_name' => 'NAAM VAN USER INVULLEN'));
         if ($tmhOAuth->response['code'] == 200) {
             $content = json_decode($tmhOAuth->response['response']);
         } else {
             $tmhOAuth->pr(htmlentities($tmhOAuth->response['response']));
         }
         $output = array();
         foreach ($content as $entry) {
             $output[] = array('text' => $entry->text, 'created_at' => date('d/m/Y G:i', strtotime($entry->created_at)));
         }
         $object = new stdClass();
         $object->output = $output;
         $object->timestamp = time();
         $cache->save($object, $cacheId, array('Twitter_Webservice'));
         if ($this->_getParam('version', '1') == '2') {
             foreach ($output as $key => $tweet) {
                 $output[$key]['text'] = $this->processLinks($tweet['text']);
             }
         }
     }
     echo json_encode($output);
 }
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:49,代码来源:TwitterController.php


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