Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
<?php
namespace space\report;
class MyReport extends \koolreport\KoolReport {
function settings()
{
return array(
"dataSources"=>array(
"apiarray"=>array(
"class"=>'\koolreport\datasources\ArrayDataSource',
"dataFormat"=>"associate",
)
)
);
}
function setup()
{
//START CODE API
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'URL',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: TOKEN'
),
));
$response = curl_exec($curl);
curl_close($curl);
//END CODE API
$this->src("apiarray")->load($data)
->pipe(...)
pipe($this->dataStore("result"));
}
}
can you explain me in more detail
If you are able to receive the $response in json, you do:
...
$response = curl_exec($curl);
curl_close($curl);
$data = json_decode($response,true);
$this->src("apiarray")->load($data)
->pipe(...)
...
Of course, I do not know your structure of your json which you need to work out, it may need some transformation before it can be used. the $data in the load function need to be in this format (array of associate array),
[
["name"=>"Peter","age"=>39],
["name"=>"John","age"=>20],
]
Saying "it does not work" is the most meaningless thing one can say and provides us with no information whatsoever to help solving the problem for you. Provide your code, screenshots of errors or your problem, and describe what the problem is exactly and specifically.
I will close this post and will answer you in your new post #2345. We try to keep a topic on single issue for single person and also eliminate duplicate topics. Please continue in your new topic.
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo