dynata/ rex-sdk-php
1.0.2
2022-08-29 14:37 UTC
Requires
- php: >=7.4
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- phpdocumentor/reflection-docblock: ^5.3
- symfony/property-access: ^5.3
- symfony/serializer: ^5.3
Requires (Dev)
- phpstan/phpstan: ^1.1
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: 3.*
This package is auto-updated.
Last update: 2024-09-19 23:14:31 UTC
README
用于构建并与Dynata Respondent Exchange (REX)交互的包
快速入门
注意:如果您没有"account_id",可以使用null
机会注册表
实例化注册表客户端
use Dynata\Rex\Core\Security\BasicCredentialsProvider; use Dynata\Rex\Core\Security\StringSigner; use Dynata\Rex\Registry\Registry; $interval = \DateInterval::createFromDateString('1 day'); $creds_provider = new BasicCredentialsProvider("REX_ACCESS_KEY", "REX_SECRET_KEY"); $string_signer = new StringSigner($creds_provider, $interval); $registy = new Registry("REX_REGISTRY_BASE_URL", $string_signer);
列出机会通知
$shardConfig = new ShardConfig(1, 1); $notification_payload = new ReceiveNotificationsInput(1, $shardConfig, "account_id"); $registry->recieveNotifications($notification_payload);
确认通知
$ack_notification_payload = new AckNotificationsInput("account_id", [1, 2 , 3]); $registry->ackNotifications($ack_notification_payload);
获取机会
$registry->getOpportunity(['id'=> 1]);
列出项目机会
$list_project_opportunities_payload = new ListProjectOpportunitiesInput("account_id", 1); $registry->listProjectOpportunities($list_project_opportunities_payload);
下载集合
$download_collection_payload = new DownloadCollectionInput("account_id", 1); $registry->downloadCollection($list_project_opportunities_payload);
受访者网关
实例化网关客户端
use Dynata\Rex\Core\Security\BasicCredentialsProvider; use Dynata\Rex\Core\Security\StringSigner; $interval = \DateInterval::createFromDateString('1 day'); $creds_provider = new BasicCredentialsProvider("REX_ACCESS_KEY", "REX_SECRET_KEY"); $string_signer = new StringSigner($creds_provider, $interval); $gateway = new Gateway("REX_BASE_URL", $string_signer);
创建上下文
$context = new CreateContextInput("unique_context_id", "account_id", "expiration", [ "ctx" => "a987dsglh34t435jkhsdg98u", "gender" => "male", "postal_code" => "60081", "birth_date" => "1959-10-05", "country" => "US" ] ); $gateway->createContext($context);
获取上下文
$context = new GetContextInput("unique_context_id", "account_id"); $gatway->getContext($context);
过期上下文
$context = new ExpireContextInput("unique_context_id", "account_id"); $gatway->expireContext($context);
创建或更新受访者
$respondent = new PutRespondentInput( "unique_respondent_id", "en", "US", "female", "1999-09-09", "60081" ); $gatway->putRespondent($respondent);
创建或更新受访者答案
$respondent = new PutRespondentAnwsersInput( "unique_respondent_id", "US", [ [ "id" => -9223372036854776000, "answers" => [ -9223372036854776000 ] ] ] ); $gatway->putRespondentAnswers($respondent);
列出属性
$list_attributes = new ListAttributesInput(); $list_attributes->page_size = 1; $gateway->listAttributes($list_attributes);
获取属性信息
$get_attribute_info = new GetAttributeInfoInput(1); $gateway->getAttributeInfo($get_attribute_info);