本文整理汇总了PHP中TwitterOAuth::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP TwitterOAuth::toArray方法的具体用法?PHP TwitterOAuth::toArray怎么用?PHP TwitterOAuth::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwitterOAuth
的用法示例。
在下文中一共展示了TwitterOAuth::toArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
$search = false;
if (isset($_POST['q']) || isset($_GET['q'])) {
$search = true;
$keyword = isset($_POST['q']) ? $_POST['q'] : $_GET['q'];
$keyword = trim(strip_tags($keyword));
$params = array();
if (count($_POST)) {
$params = array('q' => $keyword, 'count' => 20, 'include_entities' => 1);
} else {
if (count($_GET)) {
$params = $_GET;
}
}
if ($keyword) {
$data = $twitter->get('search/tweets', $params);
$data = $twitter->toArray($data);
}
}
if ($search) {
// echo '<pre>';
// print_r($data);
// echo '</pre>';
// exit;
}
$count = 0;
$nav = isset($data['search_metadata']) && $data['search_metadata']->next_results ? true : false;
?>
<!doctype html>
<html>
<head>
示例2: TwitterOAuth
@session_start();
require_once 'src/twitteroauth.php';
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
if (!$twitter->isLogged()) {
$twitter->redirect('/');
}
// https://dev.twitter.com/docs/api/1.1
/* Some example calls */
//$twitter->get('users/show', array('screen_name' => 'abraham'));
//$twitter->post('statuses/update', array('status' => date(DATE_RFC822)));
//$twitter->post('statuses/destroy', array('id' => 5437877770));
//$twitter->post('friendships/create', array('id' => 9436992));
//$twitter->post('friendships/destroy', array('id' => 9436992));
// get user info
$user = $twitter->get('account/verify_credentials');
$user = $twitter->toArray($user);
extract($user);
// get user account settings
$settings = $twitter->get('account/settings');
$settings = $twitter->toArray($settings);
// rate limit exceeded
if (isset($user['errors'])) {
echo '<pre>';
print_r($twitter->getRateLimit());
echo '</pre>';
exit;
}
//echo '<pre>';
//print_r($user);
//exit;
?>