diff --git a/.env-example b/.env-example index 9743233..071d9d8 100644 --- a/.env-example +++ b/.env-example @@ -27,4 +27,9 @@ BRAND_NAME=Acme, Inc. CODE= NUMBER= REQUEST_ID= -WORKFLOW_ID=4 \ No newline at end of file +WORKFLOW_ID=4 + +# Reports API +ACCOUNT_ID= +FILE_ID= +REQUEST_ID= diff --git a/.gitignore b/.gitignore index 1209ce6..8192521 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ vendor private.key .env .DS_Store +composer.phar +report.zip +composer-setup.php diff --git a/reports/create-async-report.php b/reports/create-async-report.php new file mode 100644 index 0000000..916262c --- /dev/null +++ b/reports/create-async-report.php @@ -0,0 +1,23 @@ + "SMS", + "account_id" => ACCOUNT_ID, + "direction" => "outbound" +]; +$body = json_encode($data); +$options = ["http" => [ + "method" => "POST", + "header" => ["Authorization: Basic " . $auth, + "Content-Type: application/json"], + "ignore_errors" => true, + "content" => $body + ]]; +$context = stream_context_create($options); +// make the request +$response = file_get_contents($url, false, $context); +var_dump($response); diff --git a/reports/get-report-status.php b/reports/get-report-status.php new file mode 100644 index 0000000..126d1ed --- /dev/null +++ b/reports/get-report-status.php @@ -0,0 +1,16 @@ + [ + "method" => "GET", + "header" => ["Authorization: Basic " . $auth], + "ignore_errors" => true + ]]; +$context = stream_context_create($options); +// make the request +$response = file_get_contents($url, false, $context); +var_dump($response); diff --git a/reports/get-report.php b/reports/get-report.php new file mode 100644 index 0000000..f412eeb --- /dev/null +++ b/reports/get-report.php @@ -0,0 +1,21 @@ + [ + "method" => "GET", + "header" => ["Authorization: Basic " . $auth], + "ignore_errors" => true + ]]; +$context = stream_context_create($options); +// stream to download +$stream = fopen($url, 'rb', false, $context); +// stream to local file +$fp = fopen("report.zip", 'wb'); +// connect the hoses together +stream_copy_to_stream($stream, $fp); +fclose($stream); +fclose($fp);