2
1

More than 5 years have passed since last update.

AWS SDK for PHP 3.xでAmazon KinesisのPUT/GETを試す小さなサンプル

Posted at

前提

  • リージョン:東京
  • AWS SDK for PHP 3.xがインストール済であること
  • credencialまたはIAMロールが登録済であること
  • ストリーム(test)が作成済みであること

サンプル

put.php
<?php
require './vendor/autoload.php';

$client = new Aws\Kinesis\KinesisClient([
        'version' => 'latest',
        'region' => 'ap-northeast-1'
]);

$result = $client->putRecords([
        'Records' => [
                [
                        'Data' => 'hogehoge',
                        'PartitionKey' => 'hoge',
                ],
        ],
        'StreamName' => 'test',
]);
var_dump($result);
get.php
<?php
require './vendor/autoload.php';

$client = new Aws\Kinesis\KinesisClient([
        'version' => 'latest',
        'region' => 'ap-northeast-1'
]);

$sharedIDResult = $client->getShardIterator([
        'ShardId' => 'shardId-000000000000',
      'ShardIteratorType' => 'TRIM_HORIZON',
//        'ShardIteratorType' => 'AFTER_SEQUENCE_NUMBER',
        'StreamName' => 'test',
//        'StartingSequenceNumber' => 'xxxx'
]);

$ite = $sharedIDResult['ShardIterator'];

$result = $client->getRecords([
       'ShardIterator' => $ite,
]);
var_dump($result);

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1