Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

72 lines (52 sloc) 2.278 kB

Installation

  1. Add this bundle and Abraham Williams' Twitter library to your project as Git submodules:

      $ git submodule add git://github.com/kriswallsmith/KrisTwitterBundle.git src/Bundle/Kris/TwitterBundle
      $ git submodule add git://github.com/abraham/twitteroauth.git src/vendor/twitteroauth
    
  2. Add the TwitterOAuth class to your project's autoloader bootstrap script:

      // src/autoload.php
      $loader->registerPrefixes(array(
          'TwitterOAuth' => __DIR__.'/vendor/twitteroauth/twitteroauth',
      ));
    
  3. Add this bundle to your application's kernel:

      // application/ApplicationKernel.php
      public function registerBundles()
      {
          return array(
              // ...
              new Bundle\Kris\TwitterBundle\KrisTwitterBundle(),
              // ...
          );
      }
    
  4. Configure the twitter service in your YAML or XML configuration:

      # application/config/config.yml
      twitter.api:
        alias: twitter
        consumer_key: 123456879
        consumer_secret: s3cr3t
    
      # application/config/config.xml
      <twitter:api
        alias="twitter"
        consumer_key="123456879"
        consumer_secret="s3cr3t"
      />
    

Using Twitter @Anywhere

A templating helper is included for using Twitter @Anywhere. To use it, first call the ->setup() method toward the top of your DOM:

  <?php echo $view['twitter_anywhere']->setup() ?>
</head>

Once that's done, you can queue up JavaScript to be run once the library is actually loaded:

<span id="twitter_connect"></span>
<?php $view['twitter_anywhere']->queue('T("#twitter_connect").connectButton()') ?>

Finally, call the ->initialize() method toward the bottom of the DOM:

  <?php $view['twitter_anywhere']->initialize() ?>
</body>

Configuring Twitter @Anywhere

You can define a custom callback URL to use for the Twitter @Anywhere authentication process by setting a kris.twitter.anywhere.callback_url parameter in your configuration:

# application/config/config.yml
parameters:
  kris.twitter.anywhere.callback_url: http://example.org/callback
Jump to Line
Something went wrong with that request. Please try again.