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.



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

Facebook configuartion array should have the following keys:

  • 'app_key'
  • 'app_secret'
  • 'access_token'

Facebook application should be set on the page The 'app_key' value should be content of the field 'App ID' displayed in dashboard. As 'app_secret' value should be set content of the field 'App Secret' displayed in dashboard.
The application should require the following Facebook user permissions: 'email', 'user_friends', 'publish_actions'. User access token must be obtained after accepting these permissions by user.



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

use Vegas\Social\Facebook\Publish;
$config = array(
    'app_key' => APP_ID,
    'app_secret' => APP_SECRET,
    'access_token' => USER_OAUTH_TOKEN

$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("");

A photo can be set by URL:


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());

Publishing post

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