curl -H "Authorization: Token token=abcdefghijklmnop" -H "Accept: application/json" 'http://www.example.com/whatever/path/to/stream'
$datastream = json_decode(<<<HEREDOC [{"id":54,"mkt_id":5,"offer_category":8,"offer_status":"T", blah blah blah, boring details etc etc HEREDOC ); str_replace("'", "\'", $datastream); $data = array(); foreach($datastream as $component) { ... and so on for values to my chunk
This question has been answered by BobRay. See the first response.
$data = json_decode(stripslashes(file_get_contents("php://input")), true);
$data = array_values(json_decode(stripslashes(file_get_contents("php://input")), true));
header("Authorization: Token token=abcdefghijklmnop"); header("Accept: application/json"); $url = 'http://www.example.com/whatever/path/to/stream';
<?php $context = stream_context_create(array( 'http' => array( 'method' => 'GET', 'header' => "Authorization: Token token=longstringauthorizationtoken\r\n" . "Accept: application/json\r\n" ) )); $result = file_get_contents("http://www.example.com/path/to/feed", false, $context); //var_dump($result); $datastream = json_decode($result); //str_replace("'", "\'", $datastream); $data = array(); foreach($datastream as $component) { $productid = $component->id; $service_category_codes = $component->service_category_codes; ... and more arrays and nested arrays being called from the data stream if ($service_category_codes == array("S")) { $output_chunk = 'datastream_s_chunk'; } elseif ($service_category_codes == array("O")) { $output_chunk = 'datastream_o_chunk'; } elseif ($service_category_codes == array("C", "K")) { $output_chunk = 'datastream_ck_chunk'; }; $outputarray = array('productid' => $productid, 'offer_headline' => $offer_headline, etc etc); $output .= $modx->getChunk($output_chunk, $outputarray); } return $output;