本文整理汇总了PHP中TwitterOAuth::oAuthRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP TwitterOAuth::oAuthRequest方法的具体用法?PHP TwitterOAuth::oAuthRequest怎么用?PHP TwitterOAuth::oAuthRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TwitterOAuth
的用法示例。
在下文中一共展示了TwitterOAuth::oAuthRequest方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIDsList
function testIDsList()
{
global $THINKTANK_CFG;
$to = new TwitterOAuth('', '', '', '');
$result = $to->oAuthRequest('https://twitter.com/followers/ids.xml', array(), 'GET');
$r = array();
$r["id"] = 0;
$r['network_username'] = 'user';
$r['network_user_id'] = 0;
$r['last_status_id'] = 0;
$r['last_page_fetched_replies'] = 0;
$r['last_page_fetched_tweets'] = 0;
$r['total_posts_in_system'] = 0;
$r['total_replies_in_system'] = 0;
$r['total_follows_in_system'] = 0;
$r['total_users_in_system'] = 0;
$r['is_archive_loaded_replies'] = 0;
$r['is_archive_loaded_follows'] = 0;
$r['crawler_last_run'] = '1/1/2007';
$r['earliest_reply_in_system'] = 0;
$r['api_calls_to_leave_unmade_per_minute'] = 5;
$r['avg_replies_per_day'] = 0;
$r['is_public'] = 1;
$r['is_active'] = 1;
$r['network'] = 'twitter';
$i = new Instance($r);
$api = new CrawlerTwitterAPIAccessorOAuth('111', '222', $THINKTANK_CFG['oauth_consumer_key'], $THINKTANK_CFG['oauth_consumer_secret'], $i, $THINKTANK_CFG['archive_limit']);
$users = $api->parseXML($result);
$next_cursor = $api->getNextCursor();
//echo 'Next cursor is ' . $next_cursor;
$this->assertTrue($next_cursor == '1326272872342936860');
}
示例2: testIDsList
public function testIDsList()
{
$to = new TwitterOAuth('', '', '', '');
$result = $to->oAuthRequest('https://twitter.com/followers/ids.xml', 'GET', array());
$api = new CrawlerTwitterAPIAccessorOAuth('111', '222', 1234, 1234, 5, 3200, 5, 350);
$users = $api->parseXML($result);
$next_cursor = $api->getNextCursor();
$this->assertTrue($next_cursor == '1326272872342936860');
}
示例3: testIDsList
function testIDsList()
{
$to = new TwitterOAuth('', '', '', '');
$result = $to->oAuthRequest('https://twitter.com/followers/ids.xml', array(), 'GET');
$api = new CrawlerTwitterAPIAccessorOAuth('111', '222', $THINKTANK_CFG['oauth_consumer_key'], $THINKTANK_CFG['oauth_consumer_secret'], $i, $THINKTANK_CFG['archive_limit']);
$users = $api->parseXML($result);
$next_cursor = $api->getNextCursor();
//echo 'Next cursor is ' . $next_cursor;
$this->assertTrue($next_cursor == '1326272872342936860');
}
示例4: testIDsList
public function testIDsList()
{
global $THINKUP_CFG;
$to = new TwitterOAuth('', '', '', '');
$result = $to->oAuthRequest('https://twitter.com/followers/ids.xml', 'GET', array());
$api = new CrawlerTwitterAPIAccessorOAuth('111', '222', 1234, 1234, $this->getTestInstance(), 3200);
$users = $api->parseXML($result);
$next_cursor = $api->getNextCursor();
//echo 'Next cursor is ' . $next_cursor;
$this->assertTrue($next_cursor == '1326272872342936860');
}
示例5: httpRequest
/**
* Process HTTP request.
* @param string URL
* @param array POST data
* @return mixed
* @throws TwitterException
*/
private function httpRequest($url, $postData = NULL)
{
if (!$this->oauth instanceof TwitterOAuth) {
throw new TwitterException('Not authorized.');
}
$result = $this->oauth->oAuthRequest($url, $postData ? 'POST' : 'GET', $postData);
if (strpos($url, 'json')) {
$payload = @json_decode($result);
// intentionally @
} else {
$payload = @simplexml_load_string($result);
// intentionally @
}
if (empty($payload)) {
throw new TwitterException('Invalid server response');
}
return $payload;
}
示例6: executeTwitterPost
public function executeTwitterPost(sfWebRequest $request)
{
$activityId = $request->getParameter('id');
$activity = Doctrine::getTable('ActivityData')->findOneById($activityId);
$user = $this->getUser();
$state = $user->getAttribute('twitter_oauth_state', 0);
if (2 !== $state) {
$this->forward('twitter', 'login');
}
try {
$consumerKey = sfConfig::get('app_twitter_consumer_key');
$consumerSecret = sfConfig::get('app_twitter_consumer_secret');
$token = $user->getAttribute('twitter_oauth_token');
$secret = $user->getAttribute('twitter_oauth_secret');
$oauth = new TwitterOAuth($consumerKey, $consumerSecret, $token, $secret);
$oauth->oAuthRequest('statuses/update', 'POST', array('status' => $activity->body));
$this->redirect('@homepage');
} catch (OAuthException $e) {
$user->setAttribute('twitter_oauth_state', 0);
throw $e;
//$this->forward('twitter', 'login');
}
}
示例7: testMakingAPICall
function testMakingAPICall()
{
$to = new TwitterOAuth('', '', '', '');
$result = $to->oAuthRequest('https://twitter.com/users/show/anildash.xml', array(), 'GET');
$this->assertWantedPattern('/Anil Dash/', $result);
}
示例8: twitter_post_answer
/**
* Handles posting answer to twitter. APP requires write permission.
*
* @param int $commentID
* @return mixed
*/
function twitter_post_answer($commentID)
{
global $up_options;
if (isset($_SESSION['twitter_accesstoken']) && isset($_SESSION['twitter_accesstokensecret'])) {
$comment_text = strip_tags(get_comment_text($commentID));
if (strlen($comment_text) > 70) {
$comment_text = substr($comment_text, 0, 70) . "...";
}
$comment_text = get_comment_link($commentID) . " : " . $comment_text;
$comment_text = urldecode($comment_text);
$twitter_consumer_key = $up_options->twitter_consumer_key;
//get_option("qya_textTwitterConsumerKey");
$twitter_consumer_secret = $up_options->twitter_consumer_secret;
//get_option("qya_textTwitterConsumerSecret");
$connection = new TwitterOAuth($twitter_consumer_key, $twitter_consumer_secret, $_SESSION['twitter_accesstoken'], $_SESSION['twitter_accesstokensecret']);
return $connection->oAuthRequest("http://api.twitter.com/1/statuses/update.xml", "POST", array("status" => $comment_text));
}
}
示例9: TwitterOAuth
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, TWITTER_OAUTH_TOKEN, TWITTER_OAUTH_TOKEN_SECRET);
$searchUrl = $connection->host . "search/tweets." . $connection->format;
$sqlinstw1 = "SELECT * FROM tbl_keywords";
$resultinstw1 = mysql_query($sqlinstw1) or die(mysql_error());
while ($row = mysql_fetch_array($resultinstw1)) {
$idinstw1 = $row['id'];
$keywordNameinstw1 = $row['name'];
$searchkw = str_replace(" ", "+", $keywordNameinstw1);
$sql11instw1 = "SELECT * FROM tbl_twitter_data where project_id = '" . $idinstw1 . "'";
$result11instw1 = mysql_query($sql11instw1) or die(mysql_error());
$count11instw1 = mysql_num_rows($result11instw1);
$i = 0;
if ($count11instw1 > 0) {
$sql18instw1 = "DELETE FROM tbl_twitter_data where project_id = '" . $idinstw1 . "'";
$result18instw1 = mysql_query($sql18instw1) or die(mysql_error());
$searchResponse = $connection->oAuthRequest($searchUrl, "GET", array('q' => $searchkw, 'count' => TWITTER_COUNT_SIZE));
$searchResponse = json_decode($searchResponse);
foreach ($searchResponse as $searches) {
foreach ($searches as $search) {
if (is_object($search)) {
$i++;
$name = $search->user->name;
$screenName = $search->user->screen_name;
$tweet = $search->text;
$tweetDate = date('Y-m-d H:i:s', strtotime($search->created_at));
$insArrTw[] = "(\t\t\t\t\t\t\t'" . $idinstw1 . "',\n '" . $screenName . "',\n '" . remove_spacial_1(remove_spacial(clean_insert($name))) . "',\n '" . remove_spacial_1(remove_spacial(clean_insert($tweet))) . "',\n '" . $tweetDate . "')";
}
}
}
//$sql23insta1 = "insert into tbl_twitter_data(keywordId,screenName,name,tweet,tweetDate) values" . implode(',', $insArrTw);
//mysql_query($sql23insta1) or die(mysql_error() . "==========>sql23insta1");