Skip to content

Instantly share code, notes, and snippets.

@igun997
Created November 25, 2020 11:45
Show Gist options
  • Save igun997/dacb89d04cb93c8271a4bdbc9ce69e7c to your computer and use it in GitHub Desktop.
Save igun997/dacb89d04cb93c8271a4bdbc9ce69e7c to your computer and use it in GitHub Desktop.
Checker BPOM
<?php
$bpom = "NA1820010782-6";
$target = "https://cekbpom.pom.go.id/";
$session = "";
$header = array('Accept-Language: en');
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $target);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$data = curl_exec($curl);
curl_close($curl);
preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $data, $matches);
$cookies = array();
foreach($matches[1] as $item) {
parse_str($item, $cookie);
$cookies = array_merge($cookies, $cookie);
}
$session = $cookies["PHPSESSID"];
$pre_target = "https://cekbpom.pom.go.id/index.php/home/produk/".$session."/all/row/10/page/1/order/4/DESC/search/0/".$bpom;
$curl1 = curl_init();
curl_setopt($curl1, CURLOPT_URL, $pre_target);
curl_setopt($curl1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl1, CURLOPT_HEADER, 1);
curl_setopt($curl1, CURLOPT_HTTPHEADER, array("Cookie: PHPSESSID=$session"));
$httpCode = curl_getinfo($curl1, CURLINFO_HTTP_CODE);
$data1 = curl_exec($curl1);
curl_close($curl1);
var_dump(strpos($data1, "Data Tidak Ditemukan") === false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment