Skip to content

Instantly share code, notes, and snippets.

@ammarfaizi2
Created September 25, 2018 13:18
Show Gist options
  • Save ammarfaizi2/94ff593b018a79c1fc23984133354ba1 to your computer and use it in GitHub Desktop.
Save ammarfaizi2/94ff593b018a79c1fc23984133354ba1 to your computer and use it in GitHub Desktop.
<?php
class Q
{
public static function qurl($url, $opt = [])
{
$ch = curl_init($url);
$optf = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_USERAGENT => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0"
];
foreach ($opt as $key => $value) {
$optf[$key] = $value;
}
curl_setopt_array($ch, $optf);
$out = curl_exec($ch);
curl_close($ch);
return $out;
}
}
// Getting cookie from codashop...
Q::qurl("https://www.codashop.com",
[
CURLOPT_COOKIEFILE => getcwd()."/cookie.txt",
CURLOPT_COOKIEJAR => getcwd()."/cookie.txt",
]
);
// Going to mobile legends codashop page...
Q::qurl("https://www.codashop.com/id/mobile-legends",
[
CURLOPT_COOKIEFILE => getcwd()."/cookie.txt",
CURLOPT_COOKIEJAR => getcwd()."/cookie.txt",
]
);
date_default_timezone_set("Asia/Jakarta");
$out = Q::qurl("https://www.codashop.com/initPayment.action",
[
CURLOPT_HTTPHEADER => [
"Accept: text/plain, */*; q=0.01",
"Accept-Language: en-US,en;q=0.5",
"Accept-Encoding: gzip, deflate",
"Referer: https://www.codashop.com/id/mobile-legends",
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With: XMLHttpRequest",
"DNT: 1"
],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query(
[
"voucherPricePoint.id" => "1494",
"voucherPricePoint.price" => "1200000",
"voucherPricePoint.variablePrice" => "0",
"email" => "[email protected]",
"n" => (time() + ceil(microtime(true)/pow(10, 6))),
"userVariablePrice" => "0",
"user.userId" => "4201566",
"user.zoneId" => "2004"
]
)
]
);
$out = json_decode(gzdecode($out), true);
var_dump($out);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment