定制 somin-team/somin-api-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

somin-team/somin-api-sdk

Composer 安装命令:

composer require somin-team/somin-api-sdk

包简介

SoMin API SDK is a PHP library for making calls to SoMin API.

README 文档

README

SoMin API SDK for Somin API is a PHP library for making calls to Somin API. The library enables users for making API calls from PHP 5.6 or high.

Build Status

Example

$requester = new SimpleHttpRequester();
$authorizer = new CredentialsAuthorizer($requester);

$tokenRequest = (new UserCredential())
                        ->setUsername(USERNAME)
                        ->setPassword(PASSWORD);

// Call authorization method
$tokenResponse = $authorizer->auth($tokenRequest);

// Set bearer token to current HttpRequester
$requester->setBearer($tokenResponse->getToken());

$request = (new UserProfileData())
             ->setTexts([
                 "Hello friend!",
                 "The weather is good :)"
             ])
             ->setImageURLs([
                 "https://pbs.twimg.com/media/C6ij4CLUwAAxu9r.jpg",
                 "https://pbs.twimg.com/media/C6jO3UiVoAQYc_8.jpg"
             ])
             ->setLang('en')
             ->withAgeGroup()
             ->withEducationLevel()
             ->withGender()
             ->withIncome()
             ->withOccupation()
             ->withRelationship();
             
$userProfiler = new IndividualUserProfiler($requester);

// Call individual user profile method and get request id
$requestResponse = $userProfiler->predictIndividualUserProfile($request);

$request = (new ResponseRequest())
            ->setRequestID($requestResponse->getRequestId())
            ->setResponseClass(IndividualUserProfile::class);
            
// Call method for check current request status
$commonProcessor = new CommonProcessor($this->requester);

$numAttempts = 10;
$response = null;   /** @var $response IndividualUserProfile */

while($numAttempts-- > 0 && ($response == null || $response->getHttpCode() !== 200)) {
    sleep(self::RESPONSE_WAIT_TIME_SECONDS);
    $response = $commonProcessor->response($request);
}

var_dump($response);

Testing

  • Install PHP Unit
  • Set environment variables TEST_USERNAME and TEST_PASSWORD to SoMin API user name and password, respectively.
  • run phpunit in main directory

API Documentation

More information can be found on the SoMin developer web site.

统计信息

  • 总下载量: 1.31k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2017-12-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固