Build social media publishing directly into your PHP applications using one unified Social Media API.
Instead of integrating and maintaining multiple platform-specific APIs, the Blog2Social PHP SDK provides one consistent interface to authenticate users, connect social media accounts, and publish content across multiple social networks.
Designed for SaaS platforms, CMS solutions, AI applications, marketing tools, enterprise software and custom business applications.
- Authenticate users securely
- Connect social media accounts via OAuth
- Publish text, links, images and videos
- Support multiple social media platforms through one API
- Composer-ready
- PSR-4 compliant
- PHP 8.1+
┌──────────────────────────────┐
│ Your PHP Application │
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ Blog2Social PHP SDK │
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ Blog2Social API │
└──────────────┬───────────────┘
│
┌───────────┼───────────┐
▼ ▼ ▼
Facebook LinkedIn Instagram
▼ ▼ ▼
Threads Pinterest TikTok
... additional supported networks ...
- Authenticate Blog2Social API users
- Connect and manage social media accounts
- Publish link, image, and video posts
- Manage applications and API integrations
- PSR-4 compliant
- Composer-ready installation
- PHP 8.1+ support
The SDK is designed for PHP applications that need to create, schedule, or publish social media content without maintaining separate integrations for every platform.
Add social media publishing to your product so users can share updates, reports, listings, achievements, or announcements directly from your application.
Turn articles, pages, product updates, or editorial content into social media posts and publish them to connected social accounts.
Generate captions, campaign messages, summaries, or content variations with AI and publish approved content through one API workflow.
Trigger social media publishing from campaigns, workflows, CRM events, ecommerce actions, or scheduled content plans.
Manage multiple clients, brands, connected accounts, and publishing targets from one application layer.
Distribute company news, product updates, employer branding content, or internal announcements to approved social media channels.
Allow teams to share selected updates, events, milestones, or knowledge base content across company-managed social accounts.
Install the SDK via Composer:
composer require adenion/blog2social-api-php-sdk:dev-main- PHP 8.1 or higher
- Composer
- PHP cURL extension
- PHP JSON extension
Adenion\Blog2Social\Sdk\The Composer PSR-4 configuration maps this namespace to src/.
GitHub repository:
https://github.com/adenion/blog2social-api-php-sdk
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use Adenion\Blog2Social\Sdk\Client\Blog2SocialClient;
$service_token = 'YOUR_SERVICE_TOKEN';
$client = new Blog2SocialClient(
$service_token
);Most API requests require both a service_token and an access_token.
Authenticate the user:
$auth_response = $client
->authentication()
->authenticateUser();
$access_token = $auth_response['access_token'];Store the returned access token securely and use it for future requests:
$client = new Blog2SocialClient(
$service_token,
$access_token
);Retrieve all supported social networks:
$networks = $client
->network()
->listNetwork();
print_r($networks);Generate an authorization URL to connect a social media account.
Example: Connect a Facebook Page.
$response = $client
->connection()
->addNetwork(
1,
1,
'en'
);
header(
'Location: ' . urldecode(
$response['auth_link']
)
);
exit;0 = Profile
1 = Page
2 = Group
$connections = $client
->user()
->listUserAuthentications();
print_r($connections);The returned client_user_network_id is required for publishing posts.
$client_user_network_id = (int) 'YOUR_CLIENT_USER_NETWORK_ID';
$response = $client
->share()
->createPost(
$client_user_network_id,
[
[
'client_user_network_id' => $client_user_network_id,
'title' => 'My first API post',
'message' => 'Hello from the Blog2Social PHP SDK.',
'postFormat' => 0,
'customUrl' => 'https://example.com',
],
]
);
print_r($response);0 = Link
1 = Image
2 = Video
$response = $client
->share()
->createPost(
$client_user_network_id,
[
[
'client_user_network_id' => $client_user_network_id,
'title' => 'Image Post',
'message' => 'This is an image post.',
'postFormat' => 1,
'mediaObjects' => [
[
'type' => 'IMAGE',
'url' => 'https://example.com/image.jpg',
],
],
],
]
);$response = $client
->share()
->createPost(
$client_user_network_id,
[
[
'client_user_network_id' => $client_user_network_id,
'title' => 'Video Post',
'message' => 'This is a video post.',
'postFormat' => 2,
'mediaObjects' => [
[
'type' => 'VIDEO',
'url' => 'https://example.com/video.mp4',
],
],
],
]
);The Blog2Social API returns one result object per publication target.
Always evaluate every response item individually.
foreach ($response as $result) {
if ((int) $result['error'] === 0) {
echo 'Published successfully.';
continue;
}
echo $result['b2s_error_code'] ?? 'UNKNOWN_ERROR';
}try {
$response = $client
->share()
->createPost(
$client_user_network_id,
$posts
);
print_r($response);
} catch (Throwable $exception) {
echo '<pre>';
print_r($exception);
echo '</pre>';
}TOKEN
CONTENT
RIGHT
LOGIN
LIMIT
RATE_LIMIT
NO_DATA
$client->authentication();
$client->network();
$client->connection();
$client->categories();
$client->user();
$client->post();
$client->share();
$client->insights();
$client->postInsights();
$client->video();
$client->videoUpload();
$client->videoStatus();
$client->app();
$client->userApps();Complete API documentation is available at:
https://en.blog2social.com/social-media-api/
The documentation includes:
- Authentication
- OAuth
- Account Management
- Publishing
- Media Uploads
- Insights
- Error Codes
- API Reference
Building your own integration means maintaining separate APIs, OAuth flows, publishing endpoints, media formats, and API updates for every supported social media platform.
The Blog2Social API provides one unified interface for authentication, account management, and content publishing. Instead of implementing multiple platform-specific integrations, your application communicates with a single API while the Blog2Social platform handles network-specific differences in the background.
This reduces development effort, simplifies maintenance, and allows your application to support multiple social media platforms through one consistent implementation.
Yes.
The Blog2Social PHP SDK is an open-source client library that wraps the Blog2Social API in an object-oriented interface.
Instead of manually creating HTTP requests, handling authentication, and processing responses for every endpoint, developers can work with reusable PHP service classes that simplify authentication, account management, content publishing, media uploads, and application management.
The SDK is Composer-ready, PSR-4 compliant, supports PHP 8.1+, and is designed for production applications.
Authentication consists of two steps.
First, your application authenticates itself using its service_token. This identifies your application to the Blog2Social API.
Second, the SDK authenticates the user and returns an access_token, which is used for all subsequent API requests.
When a user connects a social media account, the Blog2Social API manages the OAuth authorization process. After successful authorization, the connected account receives a unique client_user_network_id, which is required when publishing content.
Yes.
Each authenticated user can connect multiple accounts across all supported social media platforms.
After authorization, the SDK retrieves all connected accounts together with their corresponding client_user_network_id. Your application can then select the appropriate publishing target for every request.
This makes the SDK suitable for applications that manage multiple brands, customers, workspaces, or publishing destinations.
The SDK provides one consistent publishing interface for different content types.
Depending on the capabilities of the connected social network, applications can publish:
- Link posts
- Text posts
- Image posts
- Video posts
The Blog2Social API validates requests and automatically handles platform-specific publishing requirements while your application uses one consistent publishing workflow.
A successful HTTP response does not necessarily mean that every publication succeeded.
Publishing requests may contain multiple target accounts, and each target returns its own publishing result. Applications should therefore always evaluate the individual response objects instead of relying solely on the HTTP status code.
The SDK includes examples for response evaluation and exception handling, allowing applications to detect authentication issues, permission errors, validation failures, or platform-specific publishing errors.
The Blog2Social API is the underlying REST interface that provides authentication, account management, publishing, media handling, analytics, and other services.
The PHP SDK is a lightweight client library built on top of the API. It wraps REST endpoints in reusable PHP classes, reducing boilerplate code and simplifying integration into PHP applications.
Applications written in PHP will typically use the SDK, while applications written in other programming languages can integrate directly with the REST API.
The SDK simplifies implementation, while the Blog2Social API documentation provides the complete technical reference for all available endpoints, request parameters, authentication methods, response formats, supported services, and API error codes.
API Documentation:
https://en.blog2social.com/social-media-api/
Install development dependencies:
composer installRun the test suite:
composer testphpunit/phpunit is only required for development and automated tests. It is listed under require-dev and is not installed for production consumers when Composer is run with --no-dev.
Contributions are welcome.
If you would like to contribute:
- Fork the repository
- Create a feature branch
- Commit your changes
- Open a pull request
For larger changes, please open an issue first to discuss the proposed implementation.
If you discover a security vulnerability, please report it privately and do not create a public GitHub issue.
Please contact:
customer-service@blog2social.com
For support, bug reports, and feature requests:
- GitHub Issues
- Blog2Social Support Team
This SDK is released under the MIT License.
See the LICENSE file for details.