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:
Facebook application should be set on the page http://developers.facebook.com.
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);
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');
$curl_file = curl_file_create(dirname(__DIR__) . '/test_picture.png', 'image/png', 'Test message ' . rand());
$publish->setPhoto($curl_file);
The post or picture currently set in the Publish object can be sent on user page in social service by method post().
$publish->post();