Download the PHP package friendsofsymfony/twitter-bundle without Composer
On this page you can find all versions of the php package friendsofsymfony/twitter-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download friendsofsymfony/twitter-bundle
More information about friendsofsymfony/twitter-bundle
Files in friendsofsymfony/twitter-bundle
Package twitter-bundle
Short Description Symfony FOSTwitterBundle
License MIT
Homepage http://friendsofsymfony.github.com
Informations about the package twitter-bundle
DEPRECATED
See HWIOAuthBundle instead
Introduction
This Bundle enables integration with Twitter PHP. Furthermore it also provides a Symfony2 authentication provider so that users can login to a Symfony2 application via Twitter. Furthermore via custom user provider support the Twitter login can also be integrated with other data sources like the database based solution provided by FOSUserBundle.
If you are using Symfony 2.0 switch to the branch v1.0 of TwitterBundle or use the tag 1.0.0
Installation
-
Add this bundle and Abraham Williams' Twitter library to your project as Git submodules:
$ git submodule add git://github.com/FriendsOfSymfony/FOSTwitterBundle.git vendor/bundles/FOS/TwitterBundle $ git submodule add git://github.com/kertz/twitteroauth.git vendor/twitteroauth
Note: The kertz/twitteroauth is patched to be compatible with FOSTwitterBundle
-
Register the namespace
FOS
to your project's autoloader bootstrap script://app/autoload.php $loader->registerNamespaces(array( // ... 'FOS' => __DIR__.'/../vendor/bundles', // ... ));
-
Add this bundle to your application's kernel:
//app/AppKernel.php public function registerBundles() { return array( // ... new FOS\TwitterBundle\FOSTwitterBundle(), // ... ); }
-
Configure the
twitter
service in your YAML configuration:#app/config/config.yml fos_twitter: file: %kernel.root_dir%/../vendor/twitteroauth/twitteroauth/twitteroauth.php consumer_key: xxxxxx consumer_secret: xxxxxx callback_url: http://www.example.com/login_check
-
Add the following configuration to use the security component:
#app/config/security.yml security: providers: fos_twitter: id: fos_twitter.auth firewalls: secured: pattern: /secured/.* fos_twitter: true public: pattern: /.* anonymous: true fos_twitter: true logout: true access_control: - { path: /.*, role: [IS_AUTHENTICATED_ANONYMOUSLY] }
Using Twitter @Anywhere
Note: If you want the Security Component to work with Twitter @Anywhere, you need to send a request to the configured check path upon successful client authentication (see https://gist.github.com/1021384 for a sample configuration).
A templating helper is included for using Twitter @Anywhere. To use it, first
call the ->setup()
method toward the top of your DOM:
<!-- inside a php template -->
</head>
<!-- inside a twig template -->
{{ twitter_anywhere_setup() }}
</head>
Once that's done, you can queue up JavaScript to be run once the library is actually loaded:
<!-- inside a php template -->
<span id="twitter_connect"></span>
<!-- inside a twig template -->
<span id="twitter_connect"></span>
{{ twitter_anywhere_setConfig('callbackURL', 'http://www.example.com/login_check') }}
{{ twitter_anywhere_queue('T("#twitter_connect").connectButton()') }}
Finally, call the ->initialize()
method toward the bottom of the DOM:
<!-- inside a php template -->
</body>
<!-- inside a twig template -->
{{ twitter_anywhere_initialize() }}
</body>
Configuring Twitter @Anywhere
You can set configuration using the templating helper. with the setConfig() method.
Example Custom User Provider using the FOSUserBundle
To use this provider you will need to add a new service in your config.yml
Also you would need some new properties and methods in your User model class.
And this is the TwitterUserProvider class
Finally, to get the authentication tokens from Twitter you would need to create an action in your controller like this one.
You can create a button in your Twig template that will send the user to authenticate with Twitter.
- Note: Your callback URL in your config.yml must point to your configured check_path
Remember to edit your security.yml to use this provider
All versions of twitter-bundle with dependencies
symfony/framework-bundle Version 2.*
symfony/security-bundle Version 2.0.*
kertz/twitteroauth Version *