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.
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
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2017-12-18