Developed with love by KnpLabs Hire us for your project!
36

social-post-bundle

by martin-georgiev

Symfony bundle to publish status updates on Facebook, LinkedIn and Twitter.

Scrutinizer Code Quality
Build Status
Coverage Status
Latest Stable Version

Total Downloads

Upgrading?

Check the upgrade guide.


What's this?

This is a Symfony bundle written in PHP 7.1 that wraps martin-georgiev/social-post - an easy way for simultaneous publishing to multiple social networks. Currently, it integrates with Facebook, LinkedIn and Twitter.


How to install it?

Recommended way is through Composer

composer require martin-georgiev/social-post-bundle

Integration with Symfony

Add social networks configuration

# Usually part of config.yml
social_post:
    publish_on: [facebook, linkedin, twitter]         # List which Social networks you will be publishing to and configure your access to them as shown below
    providers:
        facebook:
            app_id: "YOUR-FACEBOOK-APP-ID"
            app_secret: "YOUR-FACEBOOK-APP-SECRET"
            default_access_token: "YOUR-FACEBOOK-NON-EXPIRING-PAGE-ACCESS-TOKEN"
            page_id: "YOUR-FACEBOOK-PAGE-ID"
            enable_beta_mode: true
            default_graph_version: "v2.8"             # Optional, also supports "mcrypt" and "urandom". Default uses the latest graph version.
            persistent_data_handler: "memory"         # Optional, also supports "session". Default is "memory".
            pseudo_random_string_generator: "openssl" # Optional, also supports "mcrypt" and "urandom". Default is "openssl".
            http_client_handler: "curl"               # Optional, also supports "stream" and "guzzle". Default is "curl".
        linkedin:
            client_id: "YOUR-LINKEDIN-APP-CLIENT-ID"
            client_secret: "YOUR-LINKEDIN-APP-CLIENT-SECRET"
            access_token: "YOUR-LINKEDIN-60-DAYS-LONG-USER-ACCESS-TOKEN"
            company_page_id: "YOUR-LINKEDIN-COMPANY-PAGE-ID"
        twitter:
            consumer_key: "YOUR-TWITTER-APP-CONSUMER-KEY"
            consumer_secret: "YOUR-TWITTER-APP-CONSUMER-SECRET"
            access_token: "YOUR-TWITTER-ACCESS-TOKEN"
            access_token_secret: "YOUR-TWITTER-ACCESS-TOKEN-SECRET"

Register the bundle

# Usually your app/AppKernel.php
<?php
// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...
            new \MartinGeorgiev\SocialPostBundle\SocialPostBundle(),
        ];
        return $bundles;
    }
    // ...
}

Post a test message

# Some Symfony container aware class
<?php
//...
$message = new \MartinGeorgiev\SocialPost\Message('your test message');
$container->get('social_post')->publish($message);

Additional help

Twitter has limited features for tweet customisation. This means that for tweets only message and link values (MartinGeorgiev\SocialPost\Message instance) will be used.

Facebook doesn't support non-expiring user access tokens. Instead, you can obtain a permanent page access token. When using such tokens you can act and post as the page itself. More information about the page access tokens from the official Facebook documentation. Some Stackoverflow answers (here and here) also can of help.


License

This package is licensed under the MIT License.

MIT License

Copyright (c) 2017 Martin Georgiev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
  • Replace satooshi/php-coveralls with php-coveralls/php-coveralls
    By web-flow, 2 months ago
  • Enable coveralls reports (#16)
    By web-flow, 2 months ago
  • Merge pull request #15 from martin-georgiev/develop
    By web-flow, 2 months ago
  • Split project in two repositories (bundle and social post library) (#14)
    By web-flow, 2 months ago
  • Update link on Travis badge
    By web-flow, 7 months ago
  • Enforce code-style
    By martin-georgiev, 7 months ago
  • Merge pull request #12 from martin-georgiev/feature/move-to-phpunit-v6
    By web-flow, 10 months ago
  • Add php lint step and check dependencies with security advisories
    By martin-georgiev, 10 months ago
  • Migrate to PHPUnit v6
    By martin-georgiev, 10 months ago
  • Merge branch 'develop' of https://github.com/martin-georgiev/social-post-bundle into develop
    By martin-georgiev, 10 months ago
  • Run travis with PHP 7.2 and nightly
    By martin-georgiev, 10 months ago
  • Update README.md
    By web-flow, 10 months ago
  • Merge pull request #10 from martin-georgiev/feature/symfony-4-ready
    By web-flow, 10 months ago
  • Make the package Symfony 4 ready
    By martin-georgiev, 11 months ago
  • Merge pull request #8 from martin-georgiev/develop
    By web-flow, 1 year ago
  • Merge branch 'develop' of https://github.com/martin-georgiev/social-post-bundle into develop
    By martin-georgiev, 1 year ago
  • Update description, keywords and autoload namespace in composer.json
    By martin-georgiev, 1 year ago
  • Split the predfeined services declaration into individual files. Load them only when a social network is listed as to be used (via ’publish_on’).
    By martin-georgiev, 1 year ago
  • Minor tweak in the upgrade guide for v2
    By web-flow, 1 year ago
  • Merge pull request #7 from martin-georgiev/release/v2-0-0
    By web-flow, 1 year ago
  • Add upgrade guide and update the readme
    By martin-georgiev, 1 year ago
  • Merge pull request #6 from martin-georgiev/feature/add-linkedin-support
    By web-flow, 1 year ago
  • Fix class parameter name
    By martin-georgiev, 1 year ago
  • Style improvements
    By martin-georgiev, 1 year ago
  • Add to the linkedin provider support for user access token. This enables “user-less” update share to the company page. This token shall be renewed every 59 days at least.
    By martin-georgiev, 1 year ago
  • Fix service param
    By martin-georgiev, 1 year ago
  • Add support for company page shares in LinkedIn based on Happyr’s LinkedIn API Client
    By martin-georgiev, 1 year ago
  • Merge pull request #5 from martin-georgiev/feature/disable-provider-during-runtime
    By web-flow, 1 year ago
  • Configurations (Composer, Git, PHPUnit)
    By martin-georgiev, 1 year ago
  • Remove old SocialPost exception as now we have a Message concept
    By martin-georgiev, 1 year ago