當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Twitter::getHomeTimeline方法代碼示例

本文整理匯總了PHP中Twitter::getHomeTimeline方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twitter::getHomeTimeline方法的具體用法?PHP Twitter::getHomeTimeline怎麽用?PHP Twitter::getHomeTimeline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Twitter的用法示例。


在下文中一共展示了Twitter::getHomeTimeline方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: function

        $request_token = ['token' => Session::get('oauth_request_token'), 'secret' => Session::get('oauth_request_token_secret')];
        Twitter::reconfig($request_token);
        $oauth_verifier = false;
        if (Input::has('oauth_verifier')) {
            $oauth_verifier = Input::get('oauth_verifier');
        }
        // getAccessToken() will reset the token for you
        $token = Twitter::getAccessToken($oauth_verifier);
        if (!isset($token['oauth_token_secret'])) {
            return Redirect::route('twitter.login')->with('flash_error', 'We could not log you in on Twitter.');
        }
        $credentials = Twitter::getCredentials();
        if (is_object($credentials) && !isset($credentials->error)) {
            // $credentials contains the Twitter user object with all the info about the user.
            // Add here your own user logic, store profiles, create new users on your tables...you name it!
            // Typically you'll want to store at least, user id, name and access tokens
            // if you want to be able to call the API on behalf of your users.
            // This is also the moment to log in your users if you're using Laravel's Auth class
            // Auth::login($user) should do the trick.
            Session::put('access_token', $token);
            return Redirect::to('/')->with('flash_notice', 'Congrats! You\'ve successfully signed in!');
        }
        return Redirect::route('twitter.error')->with('flash_error', 'Crab! Something went wrong while signing you up!');
    }
}]);
Route::get('twitter/statuses', function () {
    return Twitter::getHomeTimeline(['count' => 20, 'format' => 'array']);
});
Route::get('twitter/followers', function () {
    return Twitter::getFollowersIds(['format' => 'array']);
});
開發者ID:ankitdeveloper,項目名稱:social,代碼行數:31,代碼來源:routes.php

示例2: function

    }
    return $twitterFollowersLink;
});
// SHOW TWITTER TIMELINE - #reference StatusTrait.php
HTML::macro('twitter_lookup_timeline', function ($user, $count = 20) {
    $twitterRole = Twitter::getUserTimeline(['screen_name' => $user, 'count' => $count, 'format' => 'json']);
    $parsed_json = json_decode($twitterRole, true);
    $result = '';
    //dd($parsed_json);
    foreach ($parsed_json as $key => $value) {
        $result .= $value['created_at'] . ' | ' . $value['text'] . ' | ' . $value['retweet_count'] . '<br />';
    }
    return $result;
});
HTML::macro('twitter_user_home_timeline', function ($user, $count = 20) {
    $twitterRole = Twitter::getHomeTimeline(['screen_name' => $user, 'count' => $count, 'format' => 'json']);
    $parsed_json = json_decode($twitterRole, true);
    //dd($parsed_json);
    $result = '<ul class="timeline">';
    $result .= '<li class="time-label">';
    $result .= '<span class="bg-red">';
    //$result .= '<a href="https://twitter.com/'.$user->profile->twitter_username.'" target="_blank">';
    $result .= $user->profile->twitter_username;
    //$result .= '</a>';
    $result .= '</span>';
    $result .= '</li>';
    foreach ($parsed_json as $key => $value) {
        $result .= '<li>';
        $result .= '<i class="fa fa-twitter bg-blue"></i>';
        $result .= '<div class="timeline-item">';
        $result .= '<span class="time"><i class="fa fa-clock-o"></i> ' . date('M d, y g:i A', strtotime($value['created_at'])) . '</span>';
開發者ID:jeremykenedy,項目名稱:laravel-admin,代碼行數:31,代碼來源:macros.php

示例3: parse_urls

    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_NOBODY, true);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
    curl_exec($ch);
    $rsp = curl_getinfo($ch);
    curl_close($ch);
    return $rsp['url'];
}
function parse_urls($text)
{
    return preg_replace('@(http://[^ \\)\\]]+)([\\)\\]:;"\'+-—\\.,]| |$)@e', "'<a href=\"' . resolve_redirects('\\1') . '\">\\1</a>\\2'", $text);
}
# New Twitter
require 'lib/twitterlibphp/twitter.lib.php';
$t = new Twitter($user, $pass);
$timeline_data = $t->getHomeTimeline(array('count' => TLL_POSTCOUNT));
if ($timeline_data) {
    $feed = new SimpleXmlElement($timeline_data);
    $statuses = $feed->status;
    header("Content-Type: application/atom+xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
    ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Twitter Links Timeline / <?php 
    echo $user;
    ?>
</title>
    <link rel="alternate" type="text/html" href="http://twitter.com/home"/>
    <id>tag:net.benapps.timelinelinks,/twitter.com/<?php 
    echo $user;
    ?>
開發者ID:BenWard,項目名稱:timelinelinks,代碼行數:31,代碼來源:timelinelinks.php


注:本文中的Twitter::getHomeTimeline方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。