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


PHP TwitterOAuth::redirect方法代码示例

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


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

示例1: TwitterOAuth

<?php

@session_start();
require_once 'src/twitteroauth.php';
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
if (!$twitter->isLogged()) {
    $twitter->redirect('/');
}
// get data
$data = array();
$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);
开发者ID:ajireza,项目名称:api-twitter,代码行数:31,代码来源:search_keyword.php

示例2: TwitterOAuth

<?php

@session_start();
require_once 'src/twitteroauth.php';
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
/* If the oauth_token is old redirect to the start page. */
if (isset($_REQUEST['oauth_token']) && !$twitter->validRequestToken($_REQUEST['oauth_token'])) {
    $twitter->redirect('/logout.php');
}
/* Request main access tokens from twitter */
$access_token = $twitter->refreshAccessToken($_REQUEST['oauth_verifier']);
/* Save the access tokens. Normally these would be saved in a database for future use. */
$twitter->saveAccessToken($access_token);
// redirect to start page
$twitter->redirect('/');
开发者ID:ajireza,项目名称:api-twitter,代码行数:15,代码来源:callback.php

示例3: TwitterOAuth

<?php

@session_start();
require_once 'src/twitteroauth.php';
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
if ($twitter->isLogged()) {
    $twitter->redirect('/profile.php');
}
?>

<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Twitter API</title>

<link rel="stylesheet" href="/css/reset.css" type="text/css" />
<link rel="stylesheet" href="/css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="/css/style.css" type="text/css" />

<script src="/js/jquery.js"></script>
<script src="/js/bootstrap.js"></script>

</head>


<body>

<div id="main" class="container">
   <div class="content">    
    
开发者ID:ajireza,项目名称:api-twitter,代码行数:30,代码来源:index.php

示例4: TwitterOAuth

<?php

@session_start();
require_once 'src/twitteroauth.php';
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
/* Get temporary credentials. */
$request_token = $twitter->getRequestToken(OAUTH_CALLBACK);
/* Save temporary credentials to session. */
$twitter->saveOAuthToken($request_token);
/* Get token for auth url */
$token = $request_token['oauth_token'];
// if connection code ok - redirect to auth url
if ($twitter->http_code == 200) {
    $twitter->redirect($twitter->getAuthorizeURL($token));
} else {
    echo 'Could not connect to Twitter. Refresh the page or try again later.';
    exit;
}
开发者ID:ajireza,项目名称:api-twitter,代码行数:18,代码来源:login.php


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