Skip to content

Instantly share code, notes, and snippets.

@guangrei
Created November 7, 2018 14:54
Show Gist options
  • Save guangrei/58aed892b0aff2df3127b397c654a6cb to your computer and use it in GitHub Desktop.
Save guangrei/58aed892b0aff2df3127b397c654a6cb to your computer and use it in GitHub Desktop.
fix json on iis response
<?php
use Clue\React\Buzz\Browser;
use Psr\Http\Message\ResponseInterface;
require "vendor/autoload.php";
$url = "http://jendela.data.kemdikbud.go.id/api/index.php/cwilayah/wilayahKabGet";
$loop = React\EventLoop\Factory::create();
$browser = new Browser($loop);
$browser->get($url)->then(
function (ResponseInterface $response) {
$fixJson = preg_replace('/^[^\{]+/','',$response->getBody());
var_dump(json_decode($fixJson, true));
},
function (Exception $error) {
echo "error: ".$error->getMessage();
}
);
$loop->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment