2017 © Pedro Peláez
 

silverstripe-module sstwitter

A silverstripe module to integrate Silverstripe with Twitter

image

micmania1/sstwitter

A silverstripe module to integrate Silverstripe with Twitter

  • Saturday, July 5, 2014
  • by micmania1
  • Repository
  • 2 Watchers
  • 10 Stars
  • 71 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 8 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

SSTwitter

SSTwitter is a Silverstripe module to allow simple integration between Twitter & Silverstripe., (*1)

Features

  • CMS interface to integrate Silverstripe with a Twitter application & connect an account to the website.
  • Connect/Disconnect Member's to Twitter accounts.
  • Enable/Disable Twitter login through the CMS.
  • Developer Access to Twitter API through PHPTwitter.

Usage

$TwitterConnectURL (TwitterApp::connect_url()) This displays a link where a logged in user will be taken through the Twitter authentication process to connect their Twitter account., (*2)

$TwitterDisconnectURL (TwitterApp::disconnect_url()) This will disassociate the Twitter account from the Member., (*3)

$TwitterLoginURL (TwitterApp::login_url()) This will return a url whereby the user can login to their Silverstripe account through Twitter where previously connected., (*4)

<a href="$TwitterConnectURL">Connect</a><br />
<a href="$TwitterDisconnectURL">Disconnect</a><br />
<% if TwitterLoginURL %>
    <a href="$TwitterLoginURL">Login</a>
<% else %>
    Twitter Login is disabled.
<% end_if %>

Extending

SSTwitter uses PHPTwitter for its Twitter Authentication which has a central Twitter->api() method which handles all API requests. This means you can easily harness its power to interact directly with Twitter. Below is an example of how you would get the latest tweets for the account connected to your website., (*5)

In Page_Controller.php:, (*6)

public function LatestTweets($count = 3) {

    $tweets = new ArrayList();

    $twitterApp = TwitterApp::get()->first();
    $twitter = $twitterApp()->getTwitter(); // Access the PHPTwitter interface
    $twitter->setAccess(new OauthToken($twitterApp->TwitterAccessToken, $twitterApp->TwitterAccessSecret));

    // Get the latest Tweets
    if($twitter->hasAccess()) {
        $result = $twitter->api("1.1/statuses/user_timeline.json", "GET", array(
            "screen_name" => $twitterApp->TwitterScreenName,
            "count" => (int) $count
        ));

        if($result->statusCode() == 200) {
            $json = json_decode($result->body(), true);
            if(count($json) > 0) {
                foreach($json as $tweet) {
                    $tweets->push(array(
                        "Tweet" => $tweet['text'],
                        "Created" => $tweet['created_at'],
                        "Link" => "http://www.twitter.com/".rawurlencode($tweet['user']['screen_name'])."/status/".rawurlencode($tweet['id_str'])
                    ));
                }
            }
        }
    }
    return $tweets;
}

In Page.ss, (*7)

<% if LatestTweets %>
    <ul>
        <% loop LatestTweets %>
            <li>$Tweet - <a href="$Link">$Created</a></li>
        <% end_loop %>
    </ul>
<% end_if %>

The Versions

05/07 2014

1.1.x-dev

1.1.9999999.9999999-dev

A silverstripe module to integrate Silverstripe with Twitter

  Sources   Download

15/12 2013

dev-master

9999999-dev

A silverstripe module to integrate Silverstripe with Twitter

  Sources   Download

15/12 2013

1.1.4

1.1.4.0

A silverstripe module to integrate Silverstripe with Twitter

  Sources   Download

12/08 2013

1.1.3

1.1.3.0

A silverstripe module to integrate Silverstripe with Twitter

  Sources   Download

25/06 2013

1.1.2

1.1.2.0

A silverstripe module to integrate Silverstripe with Twitter

  Sources   Download

01/04 2013

1.1.0

1.1.0.0

A silverstripe module to integrate Silverstripe with Twitter

  Sources   Download

The Requires

 

24/03 2013

1.0.x-dev

1.0.9999999.9999999-dev

A silverstripe module to integrate Silverstripe with Twitter

  Sources   Download

The Requires

 

24/03 2013

1.0.0

1.0.0.0

A silverstripe module to integrate Silverstripe with Twitter

  Sources   Download

The Requires