Hack by the Beach in Jakarta

Posted on

On the past weekend, we participated in the BCA Finhacks 2016 Hackathon. It was a hackathon event at the Segarra in Jakarta Ancol beach.
There atmosphere was very very hot and humid at the day time, but they prepared for a free flow food and drinks for every participants.

Anyway.. we were creating an App called AngpaO. It’s basically an app similar to eventbrite, but 2 extra main feature which is “live streaming” of the event and a “donation” feature using BCA E-Wallet integration. If you would like to know more about the app we have our presentation slide deck uploaded here.

Our team were called “Opcode” and consisted by 3 people:
Ihsan Fauzi Rahman (
Firman Gautama (ADSKOM)
Supardi (Lippo X)

What our team have done in 24 hours time frame.

1. Reverse Engineered the PHP BCA Finhacks SDK.
– Extract bca (composer phar) file into raw php.
– Implement code hook to cache ‘access_token’ from Oauth2 class from bca sdk.
— Why? Because on the briefing yesterday morning (the 1st day), we only have limit to 5 access_token request/min, and the bca sdk didn’t cache it. We were worry that during the development we could be throttled.

2. Created PHP http Wrapper for BCA API.
– Our main apps is written in NodeJS, at the present time, bca only provide sdk for php and java, so that’s why we created an internal http wrapper for our NodeJS apps.
– We implemented these following bca api on our php http wrapper:
— User Registration
— User Update
— Topup
— Payment
— History Transaction

3. Created NodeJS Frontend + API for our Web and Android App.

– We implemented these following features:
— login & register for web (+integrated with facebook account)
— user profile update
— implemented feature to create new AngpaO event.
— implemented feature to list events for other users/guest.
— implemented feature of “donation” history for event owner.
– for this, we didn’t just use bca api, because the bca api have limitation up to the last 10 transaction only. So we re-implement our own transaction history.

4. Created Android Apps (Native)

– We created a smartphone as AngpaO wallet in mind. (So every transaction should only happen via a smartphone)
– We implemented these following features:
— login & register feature from android that integrated with Facebook account
— Implemented Angpao feed events list
— Implemented Angpao event view with video live stream
— Implemented Top-up feature.
— Implemented Donate feature.
— Implemented QR code read for AngpaO event.
— Import user profile from facebook.

5. Created live streaming video+audio for our AngpaO event.
– backend: Using Wowza with RTMP & HLS protocol.
– frontend: Using jwplayer to play on the browser (we also embed this on our android apps)
– broadcaster : Using Open Broadcaster Studio and the webcam as video and audio source (for demo)


BONUS Thoughts 😀

1. The first version of BCA PHP SDK was broken. (On 18th April 2016 they gave everyone the SDK to download and test)
– How it broke? After we “reverse engineered the sdk” we found out that there are no getter for OAuth2Client dan JsonParser in their sdk main class loader.
(This was fixed at 23 April 2016 by BCA) (but to be prepared, we also have fixed the sdk our self, but at the 1st day of hackathon they told us if there is a new version of the sdk).
2. BCA API untuk fungsi payment-nya sempat error?
– format tanggal dibilang salah, padahal udah pake seperti yg di contoh: (Fixed?)
–> Seems (some) of bca api server/endpoint have different timezone (GMT+5 instead of GMT+7) (how do we know this? we looked at the transaction date from bca server response)
–> We use a work around:
– Untuk payment, make sure ‘request date’ yg dikirimkan ke server < dari current datetime di server api bca, or else bakal dianggap invalid request.
– Jadinya kita sengaja mengirimkan waktu ‘request date’ yg beberapa waktu lebih lambat untuk menghindari race condition yang menyebabkan gagal nya request ‘payment’.
3. Access point wifi nya overloaded. Karena mungkin banyak-nya device peserta yang connect ke sana. Jadinya koneksi internet nya kurang stabil.
4. The bca api sandbox suddenly disappear like 12 hours before the event start 😦
5. Not every team treated equally. 
I don’t want to point out who is who, but you can ask many other people/team that participated in the event to confirm  🙂


Script Auto Sundul Tokopedia – Auto Dink It Tokopedia

Posted on Updated on


Yak gue emang telat banget, pasti lu semua udah pada bikin dan udah pada punya juga kan yang macem beginian.


Baru2 ini bini gue bikin toko di tokopedia, terus gue ga tega and kasian lihatin bini gue nge klik “promo” tiap 1 jam sekali di website tokopedia untuk nyundul dagangan dia, Nah.. karena itu gue bikinin deh bot yg bisa bantu klik promo barang2-nya di tokopedia secara otomatis tiap satu jam sekali supaya dia kaga usah repot klik2 tiap satu jam sekali and bisa tetep fokus jaga anak di rumah 😉

LemonScrap – PHP Class Untuk Scraping Website

Posted on Updated on

Sudah hampir 2 Tahun gue ngga pernah posting blog lagi, namun mulai hari ini kayaknya gue InsyaAllah bakalan mulai nulis2 ngga jelas lagi.

Oh iya, waktu dulu gue pernah bikin tutorial tentang Basic Website Scraping dengan PHP dan cURL, nah kali ini gue mau release wrappernya untuk melakukan hal tersebut, namanya LemonScrap dan bisa di download sourcenya di sini.

Apaan sih lemonScrap?


lemonScrap is a PHP class to help basic web scraping easier by just writing some rules (at the current moment) either with regex or DOMpath.

You are free to use this class for whatever you like. The example of usage are given. in ls-*.php files.

It uses:

  • cURL (to connect to http)
  • regex (for rules parsing and modify the result)
  • DOMpath (for rules parsing)

Membuat Time in Sentence Seperti di Facebook

Posted on Updated on

Udah lama juga ya ternyata gue ngga posting di blog gue, hmm ya udah kali ini gue pengen sharing sesuatu,
yaitu caranya buat waktu yg sudah berlaku seperti di facebook berdasarkan time() (unixtime) di php.

misalnya “1 Tahun 3 bulan dan 4 hari yang lalu”

pake function timeInSentence() ini aja.

 * timeInStenence() by mrlemonade (

function timeInSentence($val, $lang = 'id', $word = 0, $x = 0, $res = array()) {

  $y = array(31536000, 2592000, 604800, 86400, 3600, 60, 1);
  $l['id'] = array('tahun', 'bulan', 'minggu', 'hari', 'jam', 'menit', 'detik');
  $l['en'] = array('year', 'month', 'week', 'day', 'hour', 'minute', 'second');

  $end['id'] = 'yang lalu';
  $end['en'] = 'ago';

  while($x < count($y)) {

    $a = $val % $y[$x];
    if($a != 0) {
      $res[$l[$lang][$x]] = floor($val/$y[$x]);
      $val = $a;
    else {
       $res[$l[$lang][$x]] = $val/$y[$x];
       $val = 0;

    return timeInSentence( $val, $lang, $word, $x + 1, $res);

  $hasil = '';
  if($word == 0)
    $word = count($l[$lang]-1);

  if($lang == 'id')
    $hasil = 'sekitar ';
  if($lang == 'en')
    $hasil = 'about ';

  $i = 0;

  foreach($res as $k => $v) {
    if($v > 0) {
      if($i == $word)

      $res2[$k] = $v;
      $key[$i] = $k;

  $bates = count($res2);
  for($i=0;$i<$bates;$i++) {
    $angka = $res2[$key[$i]];
    $kata = $key[$i];

    if($lang == 'en' && $angka > 1)
      $kata .= 's';

    if($i+1 == $bates && $word != 1) {
      if($lang == 'en')
        $angka = 'and '.$angka;

      if($lang == 'id')
        $angka = 'dan '.$angka;
    $hasil .= $angka.' '.$kata.' ';

  return trim($hasil.$end[$lang]);

contoh penggunaan:


$time = mktime(12, 40, 33, 6, 10, 2009); // 10 July 2009 12:40:33
$timediff = time() - $time;

$bar[1] = timeInSentence($timediff, 'id', 1);
$bar[2] = timeInSentence($timediff, 'id', 2);
$bar[3] = timeInSentence($timediff, 'id', 3);
$bar[4] = timeInSentence($timediff, 'id', 4);
$bar[5] = timeInSentence($timediff, 'id', 5);
$bar[6] = timeInSentence($timediff, 'id', 6);
$bar[7] = timeInSentence($timediff, 'id', 7);



    [1] => sekitar 2 tahun yang lalu
    [2] => sekitar 2 tahun dan 5 bulan yang lalu
    [3] => sekitar 2 tahun 5 bulan dan 2 minggu yang lalu
    [4] => sekitar 2 tahun 5 bulan 2 minggu dan 4 hari yang lalu
    [5] => sekitar 2 tahun 5 bulan 2 minggu 4 hari dan 5 jam yang lalu
    [6] => sekitar 2 tahun 5 bulan 2 minggu 4 hari 5 jam dan 9 menit yang lalu
    [7] => sekitar 2 tahun 5 bulan 2 minggu 4 hari 5 jam 9 menit dan 31 detik yang lalu

not bad yah? 🙂

Cara Extrak Link Dari Html

Posted on

Gimana sih cara ekstrak link dari string atau html?

gampag kok, bisa pake 2 fungsi di bawah ini

fungsi 1:

function ambil_link_ke_array($data) {
  preg_match_all('/<a.+?href(| )=(\'|")(.+?)(\'|").*?>/s', $data, $y, PREG_PATTERN_ORDER);
  if(count($y[3]) > 0) return $y[3];
  return false;

fungsi 2:

function ambil_link_ke_array($string) {
  $doc = new DOMDocument();
  $xpath = new DOMXpath($doc);
  $urls = $xpath->query("//a/@href");
  foreach($urls as $url) {
    $tmp[] = $url->nodeValue;
  return $tmp;

seandainya kita punya string html yang kusut kyk begini:

asdfjasdklfjas<a href ="" >aklsdjf</a>kldfjklasjdfklasjdfkljasdklfjasklfj askld fjsklf jaskldfj asf
asdfjasdklfjaskldfjklasjdfklasjdfkljasdklfjasklfj askld fjsklf jaskldfj asf
<p>Test paragraph bung one <a href="">text hiji</a></p>
<p>Test paragraph roro kidul <a href="">text dua</a></p>
asdfjasdklfjaskldfjklasjdfklasjdfkljasdklfjasklfj askld fjsklf jaskldfj asf
as dfkjasdklf asdklfj sfj<p>Test paragraph trisakti <a href='tilu'>text tilu</a></p>asdfasdf aslfj lasdjf

kita bakalan dapet hasil kyk begini:

    [0] =>
    [1] =>
    [2] =>
    [3] =>
    [4] => tilu