Skip to content

Instantly share code, notes, and snippets.

@iksi
Created April 3, 2015 09:36
Show Gist options
  • Save iksi/d98080d2497594985b61 to your computer and use it in GitHub Desktop.
Save iksi/d98080d2497594985b61 to your computer and use it in GitHub Desktop.
protected function filter($response, $arguments)
{
$data = json_decode($response);
$dom = new \DOMDocument;
$dom->loadHTML($data->html);
$iframe = $dom->getElementsByTagName('iframe')->item(0);
if ($iframe === null) {
return $response;
}
$src = $iframe->getAttribute('src');
$src .= (strpos($src, '?') ? '&' : '?') . http_build_query($arguments);
$iframe->setAttribute('src', $src);
$data->html = $dom->saveXML($iframe, LIBXML_NOEMPTYTAG);
return json_encode($data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment