本文整理汇总了PHP中tmhOAuth::pr方法的典型用法代码示例。如果您正苦于以下问题:PHP tmhOAuth::pr方法的具体用法?PHP tmhOAuth::pr怎么用?PHP tmhOAuth::pr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tmhOAuth
的用法示例。
在下文中一共展示了tmhOAuth::pr方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: tmhOAuth
<?php
/**
* Tweets a message from the user whose user token and secret you use.
*
* Instructions:
* 1) If you don't have one already, create a Twitter application on
* http://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
* 4) Visit the 'My Access Token' screen linked to from your application
* details page
* 5) Copy the user token and user secret into the place in this code marked
* with (A_USER_TOKEN and A_USER_SECRET)
* 6) Visit this page using your web browser.
*
* @author themattharris
*/
require '../tmhOAuth.php';
$tmhOAuth = new tmhOAuth(array('consumer_key' => 'YOUR_CONSUMER_KEY', 'consumer_secret' => 'YOUR_CONSUMER_SECRET', 'user_token' => 'A_USER_TOKEN', 'user_secret' => 'A_USER_SECRET'));
$tmhOAuth->request('POST', $tmhOAuth->url('1/statuses/update'), array('status' => 'My Twitter Message'));
if ($tmhOAuth->response['code'] == 200) {
$tmhOAuth->pr(json_decode($tmhOAuth->response['response']));
} else {
$tmhOAuth->pr(htmlentities($tmhOAuth->response['response']));
}
示例3: tmhOAuth
<?php
require 'tmhOAuth.php';
$tmhOAuth = new tmhOAuth(array('consumer_key' => 'VfUSoN1LRaKR3459c9Lzdw', 'consumer_secret' => 'ehXOa4DAqIuRdflttrNKv6UzYHXD7BPalwGLjYIlUY', 'user_token' => '99974462-JxZTu78HU7y3aqsZn2GgjzFEO1uhjSs80rswYbbG2', 'user_secret' => 'nSMSPDFESuGEh1ZNSLkxSTX0rAXoMGpmHj8kZg2Vs0'));
$tmhOAuth->request('GET', $tmhOAuth->url('1/statuses/user_timeline'));
if ($tmhOAuth->response['code'] == 200) {
$content = json_decode($tmhOAuth->response['response']);
} else {
$tmhOAuth->pr(htmlentities($tmhOAuth->response['response']));
}
$counter == 0;
foreach ($content as $entry) {
if (++$counter == 11) {
break;
}
$tweet = $entry->text;
$time = $entry->created_at;
$location = $entry->place->full_name;
$created_month = substr($time, 3, 4);
$created_day = substr($time, 7, 3);
$created_time = substr($time, 10, 6);
$created_year = substr($time, 25, 5);
$time_informat = $created_time . $created_day . $created_month . $created_year;
if (!is_null($location)) {
$time_informat = $time_informat . " at " . $location;
}
$print_line = "{tweet} <i> {time_informat}</i><br /><br />";
$print_line = str_replace("{tweet}", $tweet, $print_line);
$print_line = str_replace("{time_informat}", $time_informat, $print_line);
echo $print_line;
}
示例4: twitter
function twitter() {
require '../lib/tmhOAuth.php';
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => Config::$t_consumer_key,
'consumer_secret' => Config::$t_consumer_secret,
));
$myurl = Config::$site_url . "auth/?a=login&m=twitter";
session_start();
if(isset($_REQUEST['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' => $_REQUEST['oauth_verifier']
));
$resp = $tmhOAuth->extract_params($tmhOAuth->response['response']);
unset($_SESSION['oauth']);
setcookie('PHPSESSID', '', time()-3600, '/');
// Get stuff
$tmhOAuth->config['user_token'] = $resp['oauth_token'];
$tmhOAuth->config['user_secret'] = $resp['oauth_token_secret'];
$tmhOAuth->request('GET', $tmh->url('1/account/verify_credentials'));
$stuff = json_decode($tmhOAuth->response['response']);
$uniqid = $stuff->id;
$ident = $stuff->screen_name;
auth_routine('t', $uniqid, $ident);
} else {
$code = $tmhOAuth->request('POST', $tmhOAuth->url('oauth/request_token', ''),
array('oauth_callback' => $myurl));
if($code == 200) {
$_SESSION['oauth'] = $tmhOAuth->extract_params($tmhOAuth->response['response']);
$method = isset($_REQUEST['signin']) ? 'authenticate' : 'authorize';
header("Location: " . $tmhOAuth->url("oauth/{$method}", '')
. "?oauth_token={$_SESSION['oauth']['oauth_token']}");
} else {
// error
$tmhOAuth->pr(htmlentities($tmhOAuth->response['response']));
}
}
}
示例5: my_streaming_callback
* http://dev.twitter.com/apps
* 2) From the application details page copy the consumer key and consumer
* secret into the place in this code marked with (YOUR_CONSUMER_KEY
* and YOUR_CONSUMER_SECRET)
* 4) Visit the 'My Access Token' screen linked to from your application
* details page
* 5) Copy the user token and user secret into the place in this code marked
* with (A_USER_TOKEN and A_USER_SECRET)
* 6) In a terminal or server type:
* php /path/to/here/streaming.php
* 7) To stop the Streaming API either press CTRL-C or, in the folder the
* script is running from type:
* touch STOP
* @author themattharris
*/
function my_streaming_callback($data, $length, $metrics)
{
echo $data . PHP_EOL;
return file_exists(dirname(__FILE__) . '/STOP');
}
require '../tmhOAuth.php';
$tmhOAuth = new tmhOAuth(array('consumer_key' => 'YOUR_CONSUMER_KEY', 'consumer_secret' => 'YOUR_CONSUMER_SECRET', 'user_token' => 'A_USER_TOKEN', 'user_secret' => 'A_USER_SECRET'));
$method = 'http://stream.twitter.com/1/statuses/filter.json';
// show Tweets which contan the word twitter OR have been geo-tagged within
// the bounding box -122.41,37.77,-122.40,37.78 OR are by themattharris
$params = array('track' => 'twitter', 'locations' => '-122.41,37.77,-122.40,37.78', 'follow' => '777925');
$tmhOAuth->streaming_request('POST', $method, $params, 'my_streaming_callback');
$tmhOAuth->pr($tmhOAuth);
?>