JPN NRIC checker php wrapper | semak ic
This code is for educational purpose only. I don’t know whether it is legal or not.. so I just release it for an educational purpose only especially for university students who doing final year project. You can make your project look cool by integrating with live government system.. ![]()
test here http://api.ibnuyahya.com/jpn.class.php
or download http://api.ibnuyahya.com/jpn.class.php.txt
/** * JPN NRIC wrapper * * This class created for Educational purpose only. Use on your own risk! * * * @owner http://ibnuyahya.com * @license GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @version 1.0 */ class jpn { private $jpnUrl = 'http://www.jpn.gov.my/semakic/check.php'; private $jpnReferer = 'http://www.jpn.gov.my/semakic/index.php'; function __construct() { } function nricGrabber($nric = '') { $ckfile = tempnam("/tmp", "CURLCOOKIE"); $post_data = "nokpt=$nric&Submit=Semak"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->jpnUrl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_REFERER, $this->jpnReferer); curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); $return_data = curl_exec($ch); curl_close($ch); return $return_data; } function getNric($nric = '') { $data = $this->nricGrabber($nric); $pattern = '/<table.*?>(.*?)<\/table>/'; preg_match($pattern, $data, $matches, PREG_OFFSET_CAPTURE); $data = $matches[1][0]; $pattern = '/<span.*?>(.*?)<\/span>/'; preg_match_all($pattern, $data, $matches); return $matches[0]; } } //Sample how to use it. $ayam = new jpn(); $tekek = $ayam->getNric('790111011123'); echo '<pre>'; print_r($tekek); echo '</pre>';
*update 29/12/2011 – this code is no longer valid since JPN changed their page and filter the result.

ArafaX 7:17 am on June 9, 2011 Permalink |
I dont see any specialities from the above code on how to retrive from JPN’s database. It’s just retrieving from the same API. By the way thanks for sharing.
admin 9:46 am on June 9, 2011 Permalink |
I didn’t mentioned this wrapper is using API either. Its just a wrapper to retrieve data from JPN’s public page and you can use it in your application with your own interface.
rahmatiah 10:48 pm on December 20, 2011 Permalink |
cek ic
eyda 11:03 pm on December 28, 2011 Permalink |
check ic