Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * ml.php
- * Copyright (c) 2020 Cvar1984 <gedzsarjuncomuniti@gmail.com>
- *
- * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
- * Version 2, December 2004
- *
- * Everyone is permitted to copy and distribute verbatim or modified
- * copies of this license document, and changing it is allowed as long
- * as the name is changed.
- *
- * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
- * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- *
- * 0. You just DO WHAT THE FUCK YOU WANT TO.
- */
- /**
- * Class: Request
- *
- */
- class Request
- {
- private $ch;
- private string $proxyHost;
- private int $proxyPort;
- private string $requestCookie;
- /**
- * __construct
- *
- * @param string $proxyHost
- * @param int $proxyPort
- */
- public function __construct(string $proxyHost = '', int $proxyPort = 9050)
- {
- $this->proxyHost = $proxyHost;
- $this->proxyPort = $proxyPort;
- $this->ch = curl_init();
- $this->requestCookie = sys_get_temp_dir() . '/cookie.txt';
- }
- /**
- * request
- *
- * @param string $requestUrl
- * @param mixed $requestDatas
- * @param mixed $requestHeaders
- */
- public function request(
- string $requestUrl,
- $requestDatas = null,
- $requestHeaders
- ) {
- $ch = $this->ch;
- if ($this->proxyHost && $this->proxyPort) {
- curl_setopt($ch, CURLOPT_PROXY, $this->proxyHost);
- curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxyPort);
- curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
- }
- if ($requestDatas) {
- curl_setopt($ch, CURLOPT_POSTFIELDS, $requestDatas);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
- } else {
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
- }
- if ($requestHeaders) {
- curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
- }
- curl_setopt($ch, CURLOPT_URL, $requestUrl);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_COOKIEJAR, $this->requestCookie);
- curl_setopt($ch, CURLOPT_COOKIEFILE, $this->requestCookie);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_VERBOSE, false);
- $result = curl_exec($ch);
- if (!$result) {
- throw new \Exception(curl_error($ch));
- }
- return $result;
- }
- public function __destruct()
- {
- curl_close($this->ch);
- }
- }
- //$app = new Request('127.0.0.1', 9050);
- $app = new Request();
- $gameId = '260343526';
- $vCode = '951285';
- $redeemCodes = [
- '2020SummerCarnival',
- 'MissionSuccess',
- 'MayYourWishesComeTrue',
- ];
- foreach ($redeemCodes as $redeemCode) {
- $requestDatas = [
- 'redeemcode' => $redeemCode,
- 'gameid' => $gameId,
- 'captcha' => '',
- 'vcode' => $vCode,
- 'language' => 'en',
- ];
- $requestHeaders = [
- 'referer: https://m.mobilelegends.com/en/codexchange',
- 'origin: https://m.mobilelegends.com',
- 'content-type: application/json',
- ];
- $requestJsonData = json_encode($requestDatas);
- $response = $app->request(
- 'https://mapi.mobilelegends.com/api/sendredeem',
- $requestJsonData,
- $requestHeaders
- );
- echo 'Code: ', $redeemCode, ' Result: ', $response, PHP_EOL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement