PHPackages                             jcsp/social-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. jcsp/social-sdk

ActiveLibrary[API Development](/categories/api)

jcsp/social-sdk
===============

social api sdk

v1.2.7(4y ago)0122Apache-2.0PHPPHP &gt;=7.2CI failing

Since Jul 29Pushed 4y ago1 watchersCompare

[ Source](https://github.com/jujiao2020/social-sdk)[ Packagist](https://packagist.org/packages/jcsp/social-sdk)[ RSS](/packages/jcsp-social-sdk/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (9)Versions (18)Used By (0)

Jcsp Social Sdk
===============

[](#jcsp-social-sdk)

Jscp Social Sdk Component

Installation
------------

[](#installation)

Require this package, with composer, in the root directory of your project.

```
composer require jscp/social-sdk
```

Please note that this library requires at least PHP 7.2 installed.

Usage
-----

[](#usage)

### Init the Client Instance

[](#init-the-client-instance)

Use the bellow codes to init the client instance.

```
// Set the client config
$config = [
    // The directory to store temporary files while sharing the resources.
    // The default value is /tmp .
    'temp_storage_path' => "/tmp/temp_file",

    // A full class name or an instance, it must implement the contract \Jcsp\SocialSdk\Contract\CacheInterface .
    // The default value is \Jcsp\SocialSdk\Cache\Session::class .
    'cache' => CustomCache::class,

    // A full class name or an instance, it must implement the contract \Jcsp\SocialSdk\Contract\LoggerInterface.
    // The default value is \Jcsp\SocialSdk\Log\NoLog::class .
    'logger' => CustomLogger::class;
];

// Set the real social media name
$socialMediaName = "Youtube";

// Set the auth config
$authConfig = new \Jcsp\SocialSdk\Model\AuthConfig();
$authConfig->setClientId("Client id");
$authConfig->setClientSecret("Client secret");
$authConfig->setRedirectUrl("Oauth callback url");

// Create client instance
$factory = new \Jcsp\SocialSdk\ClientFactory($config);
$client = $factory->createClient($socialMediaName);

// Init auth data
$client->initAuth($authConfig);
```

Some functions need to provide access token data, so must pass the `$accessToken` object.

```
// Set the access token object
$accessToken = new \Jcsp\SocialSdk\Model\AccessToken();
$accessToken->setToken("Access token string");
$accessToken->setTokenSecret("Access token secret string");
$accessToken->setUserId("User id"); // optional, only used for some platforms
$accessToken->setRefreshToken("Refresh token string"); // optional, part of platforms support
$accessToken->setExpireTime($expireTimestramp); // optional, part of platforms support
$accessToken->setParams([]); // optional, for part of platforms

// Create client instance
$factory = new \Jcsp\SocialSdk\ClientFactory($config);
$client = $factory->createClient($socialMediaName);

// Init auth
$client->initAuth($authConfig, $accessToken);
```

### Authorization

[](#authorization)

#### Generate Authorization Url

[](#generate-authorization-url)

```
$authUrl = $client->generateAuthUrl();
```

#### Get Access Token

[](#get-access-token)

```
$accessToken = $client->getAccessToken(array_merge($_GET, $_POST));
```

#### Refresh Access Token

[](#refresh-access-token)

```
$allowRefreshToken = $client->allowRefreshToken();
$isAccessTokenExpired = $client->isAccessTokenExpired();
if $allowRefreshToken && $isAccessTokenExpired {
    $accessToken = $client->refreshAccessToken();
}
```

### User

[](#user)

#### Get User Profile

[](#get-user-profile)

```
// Need access token
$userProfile = $client->getUserProfile();
```

### Channel

[](#channel)

Different platforms have different names for describing the area for sharing contents, like channel in Youtube, like page in Facebook, board in Pinterest, etc. For Convenient, here use the word channel to unity the name.

#### Get Channel List

[](#get-channel-list)

```
// Need access token
$channelList = $client->getShareChannelList();
```

### Share

[](#share)

#### Can share to user

[](#can-share-to-user)

```
$canShareToUser = $client->canShareToUser();
```

#### Can share to channel

[](#can-share-to-channel)

```
$canShareToChannel = $client->canShareToChannel();
```

#### Share Video

[](#share-video)

```
// Need access token

// If the access token has expired, try to refresh it.
if ($client->allowRefreshToken() && $client->isAccessTokenExpired()) {
    $client->refreshAccessToken();
}

// Share video
$params = new \Jcsp\SocialSdk\Model\VideoShareParams();
$params->setTitle("Share Title");
$params->setDescription("Share Description");
$params->setVideoUrl("Video Url");
$params->setThumbnailUrl("Thumbnail Url");
$params->setSocialId("User Id or Channel Id");
$params->setDisplayName("Username or Channel Name"); // Some platforms need social id, other use social display name.
$params->setAccessToken("Access Token String");
$params->setIsPostToChannel(false); // true: post to channel, false: post to user
$result = $client->shareVideo($params);
```

### Simulate Share

[](#simulate-share)

Use the other way to share content.

#### Create Simulate Client

[](#create-simulate-client)

```
// Set the client config
$config = [
     // Specify these endpoint urls
    'simulate' => [
        'post_video_endpoint' => '',
        'query_post_task_endpoint' => '',
        'get_account_list_endpoint' => '',
    ],

    // A full class name or an instance, it must implement the contract \Jcsp\SocialSdk\Contract\LoggerInterface.
    // The default value is \Jcsp\SocialSdk\Log\NoLog::class .
    'logger' => CustomLogger::class;
];

// Create client instance
$factory = new \Jcsp\SocialSdk\ClientFactory($this->config);
$client = $factory->createSimulateClient();
```

#### Get Account List

[](#get-account-list)

Get a list of the active accounts.

```
$accountList = $client->getAccountList();
```

#### Make Simulate Video Post

[](#make-simulate-video-post)

To Make the simulate video post, in fact the simulate server would generate a task and return it. Save the task if which the method returned.

```
// Make a task
$params = new \Jcsp\SocialSdk\Model\SimulateVideoPostParams();
$params->setVideoUrl("Video Url");
$params->setTitle("Title");
$params->setDescription("Description");
$params->setAccount("Account");
$params->setCallbackUrl("Public Url to handle Post Result Notice");
$params->setSocialMediaName("Full Platform Name, like Youtube");
$task = $client->simPostVideo($params);

// Get task info
$taskId = $task->getTaskId(); // Important, save it.
$taskStatus = $task->getTaskStatus();
$msg = $task->getMsg(); // Message for develop
$info = $task->getInfo(); // Message for operation staff
```

#### Handle Simulate Post Callback

[](#handle-simulate-post-callback)

After a simulate post finished, the simulate server would make post's type call the callback url which specified above, to notify the client server the result about post task.

```
$requestParams = array_merge($_GET, $_POST);
$task = $client->handleSimPostCallback($requestParams);
```

#### Query A Task Info

[](#query-a-task-info)

It's hard to guarantee the callback handler always runs stably, so here provide a method to query task info manually.

```
$result = $client->queryTaskInfo("Task Id");
```

#### Task Status

[](#task-status)

See the class `\Jcsp\SocialSdk\ModelSimulatePostTask`

LICENSE
-------

[](#license)

The Component is open-sourced software licensed under the [Apache license](LICENSE).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~25 days

Recently: every ~40 days

Total

16

Last Release

1779d ago

Major Versions

v0.0.1 → v1.0.02020-08-07

PHP version history (2 changes)v0.0.1PHP &gt;7.2

v1.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/8df30f98582b14f7497bc2a6df950928c22f11fc66343ea14c8b5ba0e3c201b5?d=identicon)[jujiaoboy](/maintainers/jujiaoboy)

---

Top Contributors

[![jujiao2020](https://avatars.githubusercontent.com/u/68978881?v=4)](https://github.com/jujiao2020 "jujiao2020 (1 commits)")[![sentrychen](https://avatars.githubusercontent.com/u/10239273?v=4)](https://github.com/sentrychen "sentrychen (1 commits)")

---

Tags

phpsdk

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jcsp-social-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/jcsp-social-sdk/health.svg)](https://phpackages.com/packages/jcsp-social-sdk)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k9.5M88](/packages/openai-php-laravel)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[resend/resend-php

Resend PHP library.

617.2M42](/packages/resend-resend-php)[php-opencloud/openstack

PHP SDK for OpenStack APIs. Supports BlockStorage, Compute, Identity, Images, Networking and Metric Gnocchi

2312.4M25](/packages/php-opencloud-openstack)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
