AzineHybridAuthBundle
Symfony2 bundle to integrate the HybridAuth library to get access the API of various social networks., (*1)
See https://github.com/hybridauth/hybridauth for more details on the integrated library., (*2)
Available APIs
A lot of providers are available. See the following two links for a complete list:, (*3)
https://github.com/hybridauth/hybridauth/tree/master/hybridauth/Hybrid/Providers
https://github.com/hybridauth/hybridauth/tree/master/additional-providers, (*4)
Installation
To install AzineHybridAuthBundle with Composer just add the following to your composer.json
file:, (*5)
// composer.json
{
// ...
require: {
// ...
"azine/hybridauth-bundle": "dev-master"
}
}
Then, you can install the new dependencies by running Composerâs update command from
the directory where your composer.json
file is located:, (*6)
php composer.phar update
Now, Composer will automatically download all required files, and install them for you.
All that is left to do is to update your AppKernel.php file, and register the new bundle:, (*7)
<?php
// in AppKernel::registerBundles()
$bundles = array(
// ...
new Azine\HybridAuthBundle\AzineHybridAuthBundle(),
// ...
);
Register the routes of the AzineHybridAuthBundle:, (*8)
// in app/config/routing.yml
azine_hybrid_auth_bundle:
resource: "@AzineHybridAuthBundle/Resources/config/routing.yml"
prefix: /hybrid-auth/
If you want to store the users authentication session in the database, so the user is automatically
reconnected in the next browser session, then you need to enable this feature in the config.yml and
update your database schema either by running:, (*9)
php app/console doctrine:schema:update --force
or create a database migration and apply it, (*10)
php app/console doctrine:migrations:diff
php app/console doctrine:migrations:migrate
Create apps on your preferred social networks/providers
LinkedIn => https://www.linkedin.com/secure/developer, (*11)
Configuration
Configure at least one provider. See the links above for a list of available providers., (*12)
The providers in the "hybridauth\hybridauth\Hybrid\Providers"-folder are available by default via their ID,
the providers in the "hybridauth\additional-providers"-folder must be configured. => see the configuration
of the wrapper for the linkedIn provider below., (*13)
For the LinkedIn provider there are some extra functionalities implemented.
For all others, there's the default functionality from the HybridAuth available., (*14)
//app/config/config.yml
// Default configuration for "AzineHybridAuthBundle"
azine_hybrid_auth:
endpoint_route: azine_hybrid_auth_endpoint # the route_name where your endpoint controller (e.g. HybridEndPointController) is available
debug: false # set to true to log debug-information to the debug_file
debug_file: '%kernel.logs_dir%/hybrid_auth_%kernel.environment%.log' # location of the debug-file
store_for_user: false # set to true to store hybrid auth session data into your database for the logged in user
store_as_cookie: false # set to true if session-information should be stored as cookies (e.g. for anon. users)
providers:
# Prototype (at least one provider has to be defined)
name:
enabled: true
scope: ~ # comma-separated list of required 'access rights'
wrapper:
path: ~ # full path to the file containing the wrapper class
class: ~ # the wrapper class
keys:
key: ~ # your api-key for this provider
secret: ~ # your secret for this provider
Here's the example for the linkedin provider:, (*15)
//app/config/config.yml
azine_hybrid_auth:
linkedin:
enabled: true
scope: "r_ basicprofile, r_network"
keys:
key: %linkedin_api_key%
secret: %linkedin_api_secret%
Define the keys and secrets for linkedin in you parameters.yml.dist file., (*16)
AzineMergedBusinessNetworksProvider
This service / provider offers some confienience methods to work with business-networks (LinkedIn).
All methods expect the user to be "connected" to linkedin. If the user has not yet authorized your app
to access the data, a http-redirect will be output directly by setting the html-header-location and calling "die"., (*17)
Not cached, not paged., (*18)
Get all linkedIn contacts of the current user., (*19)
Not cached, not paged., (*20)
As of May 2015 LinkedIn has limited the api-access.
See https://developer.linkedin.com/support/developer-program-transition, (*21)
Getting the LinkedinContacts will only work if you are in a LinkedIn partner programm and are allowed to access.
See https://developer.linkedin.com/partner-programs, (*22)
getContactProfiles($pageSize = 50, $offset = 0)
Get all contacts of the current user. Cached and paged., (*23)
The function getContactProfiles($pageSize = 50, $offset = 0) get's one page of contacts from the business networks., (*24)
The first call will take a fair bit longer than the following ones, because on the first call, ALL contacts from
both networks are fetched and stored in one big array, sorted by last name. This collection is then stored in the
user session., (*25)
Contribute
Contributions are very welcome. Please fork the repository and issue your pull-request against the master branch., (*26)
The PR should:
- contain a description what the PR solves or adds to the bundle (reference existing issues if applicable)
- contain clean code with some iniline documentation and phpdocs, no "pure whitespace" changes.
- respect the Symfony best practices and coding style
- have phpunit tests covering the new feature or fix
- result in a 'green' build for your branch on travis-ci.org before you issue the PR, (*27)
Code style
You can check the code style with the php-cs-fixer
. Optionally you can set up a pre-commit hook which contains the php-cs-fixer
check. Also see https://github.com/FriendsOfPHP/PHP-CS-Fixer, (*28)
All you have to do is to move pre-commit.sample
file from commit-hooks/
to .git/hooks/
folder and rename it to pre-commit
., (*29)
php-cs-fixer
will check the style of your new added code each time you commit and apply fixes to the commit., (*30)
To run php-cs-fixer
manually, install dependencies (composer install
) and execute php vendor/friendsofphp/php-cs-fixer/php-cs-fixer --diff --dry-run -v fix --config=.php_cs.dist .
, (*31)
Build-Status ec.
, (*32)