本文整理汇总了PHP中Codebird\Codebird::setBearerToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Codebird::setBearerToken方法的具体用法?PHP Codebird::setBearerToken怎么用?PHP Codebird::setBearerToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Codebird\Codebird
的用法示例。
在下文中一共展示了Codebird::setBearerToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->config = Zend_Registry::get('config');
\Codebird\Codebird::setConsumerKey($this->config->twitter->consumerKey, $this->config->twitter->consumerSecret);
$this->cb = \Codebird\Codebird::getInstance();
if (isset($this->config->twitter->bearerToken)) {
$bearerToken = $this->config->twitter->bearerToken;
} else {
$bearerToken = $this->_fetchBearerToken();
}
\Codebird\Codebird::setBearerToken($bearerToken);
}
示例2: array
<?php
require_once 'codebird.php';
\Codebird\Codebird::setConsumerKey('oyptgFh88tVBmhXBSywcoeImQ', 'sFhwc99LjYbDxdvHZQfUPscQv6pqiP35kdAdldIclgybS5imKJ');
// static, see 'Using multiple Codebird instances'
$cb = \Codebird\Codebird::getInstance();
$cb->setToken('310088233-nlHAOtTbQVKBZq1CsUmMpjSekI1zvsbtBcgTlOnw', 'qsb8XFDBvL7bmQ1X006iMU7gmLw6EE7fr4nJODzYGnDLr');
$reply = $cb->oauth2_token();
if (isset($reply->errors)) {
echo $reply->errors[0]->message;
} else {
$bearer_token = $reply->access_token;
\Codebird\Codebird::setBearerToken($bearer_token);
$params = array('status' => 'Fish & chips woooh');
$reply = $cb->statuses_update($params);
}
示例3: __construct
/**
* Construct
* @access public
*/
public function __construct() {
// detect server environment
$root = $_SERVER['DOCUMENT_ROOT'];
$is_local = (strpos($root, 'XAMPP')) ? true : false;
// db
$options = array(
Zend_Db::ALLOW_SERIALIZATION => false
);
$params = array(
'host' => 'localhost',
'username' => 'sfsb_admin',
'password' => 'superdata',
'dbname' => 'twitter_tracker',
'options' => $options
);
if($is_local) {
$params = array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'twitter_tracker',
'options' => $options
);
}
try {
$this->db = Zend_Db::factory('Pdo_Mysql', $params);
$this->db->getConnection();
} catch (Zend_Db_Adapter_Exception $e) {
// perhaps a failed login credential, or perhaps the RDBMS is not running
if($is_local) {
// echo 'failed login credentials\n';
print_r($e);
}
} catch (Zend_Exception $e) {
// perhaps factory() failed to load the specified Adapter class
if($is_local) {
// echo 'failed to load specified adapter class\n';
print_r($e);
}
}
$this->table_name = 'tweets';
// twitter
// DEPRECATED
// $this->ts = new Zend_Service_Twitter_Search('json');
// codebird - for search
// NOTE: I will try with alex to make this work first, if it's not possible to upgrade php to 5.3 then I will write my own library referencing this:
// https://github.com/thatericsmith/simple-php-twitter-getter/blob/master/TwitterGetter.php
\Codebird\Codebird::setConsumerKey('Mr3tmdYJtDUBHFCIi0tPQw', 'yPFzdcuzEj0fc8jwuzrE4LdJhmNGnaiqlfv8aOVwGRU'); // static, see 'Using multiple Codebird instances'
$cb = \Codebird\Codebird::getInstance();
$cb->setToken('850078843-rKjQFWOzZzPSUCdEyQIJOHvQo6Yna1ohGP8El83K', 'wE6HRo7mPguFT7atpJGHURUccuW5kXYKvLa1WevS0Y');
$this->cb = $cb;
$file = "bearer.txt";
if(file_exists($file)) {
// echo "using " . $file;
// echo '<br />';
$bearer_token = file_get_contents($file);
// echo "using b token: " . $bearer_token;
// echo '<br />';
\Codebird\Codebird::setBearerToken($bearer_token);
} else {
// echo "getting new bearer token";
// echo '<br />';
$reply = $this->cb->oauth2_token();
$bearer_token = $reply->access_token;
// echo "setting new bearer toekn to file: " . $bearer_token;
// echo '<br />';
file_put_contents($file, $bearer_token);
}
$this->bearer_token = $bearer_token;
}