PHP code example of dynata / rex-sdk-php

1. Go to this page and download the library: Download dynata/rex-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dynata / rex-sdk-php example snippets


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);