Social

The module provides basic interface for publishing on Facebook, Twitter and LinkedIn. It lets to add posts and pictures on user wall and to photo gallery using API of social services.

Twitter

Configuration

To initialize Publish class you need configuration array dedicated for selected service.

Twitter configuartion array should have the following keys:

  • 'consumer_key'
  • 'consumer_secret'
  • 'token'
  • 'secret'

Twitter application should be set on the page https://apps.twitter.com/. Cofiguration values should be set according to fields: 'Consumer Key', 'Consumer Secret', 'Access Token' and 'Access Token Secret' displayed in the tab "Keys and Access Tokens".
Your Twitter application must have set at least 'Read and Write' option in the tab 'Permissions'.

Usage

Initialization

To use the module initialize Publish object for selected social service class with appropriate configuration array.

use Vegas\Social\Twitter\Publish;
$config = array(
    'consumer_key' => TWITTER_CONSUMER_KEY,
    'consumer_secret' => TWITTER_CONSUMER_SECRET,
    'token' => TWITTER_USER_TOKEN,
    'secret' => TWITTER_USER_SECRET
);

$publish = new Publish($config);

Preparing post

Publish interface contains a set of unified methods for post configuration.

$publish->setMessage("Post text")->setTitle("Post title")->setLink("http://amsterdamstandard.com/");

A photo can be set by URL:

$publish->setPhoto('http://www.toughzebra.com/wp-content/uploads/Amsterdam.Standard.Logo_.png');

For Facebook and Twitter photo can be set also by CURL:
$curl_file = curl_file_create(dirname(__DIR__) . '/test_picture.png', 'image/png', 'Test message ' . rand());
$publish->setPhoto($curl_file);

Publishing post

The post or picture currently set in the Publish object can be sent on user page in social service by method post().

$publish->post();