what is the best way to read online api data (html)
$dom = new DOMDocument();
$dom->loadHTML(file_get_contents($url));
foreach($dom->getElementsByTagName('tr') as $node) { ... }
$result = json_decode(file_get_contents($url));
echo $result->{"test"};
its json, i wanna do it in html not phpQuote:
What type of data is the api returning? JSON or plain html?
If it's plain html you could do something like this in php:
[Only registered and activated users can see links. Click Here To Register...]Code:$dom = new DOMDocument(); $dom->loadHTML(file_get_contents($url)); foreach($dom->getElementsByTagName('tr') as $node) { ... }
If it's json then:
Instead of file_get_contents you could also use [Only registered and activated users can see links. Click Here To Register...].Code:$result = json_decode(file_get_contents($url)); echo $result->{"test"};
ye but i can use different ways, like fetch ajax jquery p5js, all can do the job but someone told me i dont recommend jquery for api requests, im new i dont know the differents between them, thats why im asking what should i useQuote:
You can't process json in html. If you don't want to do it in php you could use javascript.
It depends on what you want to do. But apart from this I'd always process api requests server sided (e.g. php) and return their output with json so that javascript can handle that.Quote:
ye but i can use different ways, like fetch ajax jquery p5js, all can do the job but someone told me i dont recommend jquery for api requests, im new i dont know the differents between them, thats why im asking what should i use