Skip to content

Commit

Permalink
Merge pull request #34 from dblock/php
Browse files Browse the repository at this point in the history
Added PHP subscriber sample.
  • Loading branch information
melchii committed Mar 10, 2020
2 parents 78423bc + 819c216 commit 9746874
Show file tree
Hide file tree
Showing 8 changed files with 556 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -41,6 +41,10 @@ Examples of interacting with the AWS Data Exchange API from the data subscriber

* [all-entitled-datasets](subscribers/cpp/all-entitled-datasets): Lists all data sets one is subscribed to.

### PHP

* [all-entitled-datasets](subscribers/php/all-entitled-datasets): Lists all data sets one is subscribed to.

## Provider Samples

Examples of interacting with the AWS Data Exchange API from the data provider side can be found in [/providers](providers).
Expand Down
2 changes: 1 addition & 1 deletion subscribers/cpp/all-entitled-datasets/README.md
@@ -1,4 +1,4 @@
# All Entitled Data Sets
# All Entitled Data Sets (C++)

This sample retrieves a list of all subscriber's entitled data sets.

Expand Down
1 change: 1 addition & 0 deletions subscribers/php/all-entitled-datasets/.gitignore
@@ -0,0 +1 @@
vendor
26 changes: 26 additions & 0 deletions subscribers/php/all-entitled-datasets/README.md
@@ -0,0 +1,26 @@
# All Entitled Data Sets (PHP)

This sample retrieves a list of all subscriber's entitled data sets.

To run the sample, install the [AWS SDK for PHP](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/welcome.html) and install dependencies via [Composer](https://getcomposer.org/doc/00-intro.md).

```
$ composer install
```

To run the sample, set `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN` and `AWS_REGION`.

```
$ php all-entitled-datasets.php
prod-zg4u6tpyxud5i/7ae12084f47ea658ab62ee90edd513dd: NYC Property Sales 2014
Over 80,000 property sales in New York City in 2014
prod-zg4u6tpyxud5i/05964b659bbcb607d43c0d5845838e7f: NYC Property Sales 2015
Over 80,000 property sales in New York City in 2015
prod-zg4u6tpyxud5i/fc19d00c8780199e4fccd21f4834c905: NYC Property Sales 2018
A table of 80,000+ New York City property sales occurring in 2018, organized by borough, including sale price and sale date.
prod-zg4u6tpyxud5i/7d8f73e3c5acdde79fd2874dd98afdcd: NYC Property Sales 2016
Over 80,000 property sales in New York City in 2016
prod-zg4u6tpyxud5i/50782dc315b94e46fdbd4a12cec6820e: NYC Property Sales 2017
Records of over 80,000 property sales transactions.
```
21 changes: 21 additions & 0 deletions subscribers/php/all-entitled-datasets/all-entitled-datasets.php
@@ -0,0 +1,21 @@
<?php

require 'vendor/autoload.php';

$sharedConfig = [
'region' => 'us-east-1',
'version' => 'latest'
];

$sdk = new Aws\Sdk($sharedConfig);

$dx = $sdk->createDataExchange();

$result = $dx->listDataSets(['Origin' => 'ENTITLED']);

foreach ($result['DataSets'] as $data_set) {
echo $data_set['OriginDetails']['ProductId'] . '/' . $data_set['Name'] . "\n" .
' ' . $data_set['Description'] . "\n";
}

?>
5 changes: 5 additions & 0 deletions subscribers/php/all-entitled-datasets/composer.json
@@ -0,0 +1,5 @@
{
"require": {
"aws/aws-sdk-php": "^3.133"
}
}

0 comments on commit 9746874

Please sign in to comment.