Created
November 7, 2018 14:54
-
-
Save guangrei/58aed892b0aff2df3127b397c654a6cb to your computer and use it in GitHub Desktop.
fix json on iis response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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