Advertisement
P22DX

Mobile legend redeem

Jul 21st, 2020
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.39 KB | None | 0 0
  1. <?php
  2. /**
  3.  * ml.php
  4.  * Copyright (c) 2020 Cvar1984 <gedzsarjuncomuniti@gmail.com>
  5.  *
  6.  *            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  7.  *                    Version 2, December 2004
  8.  *
  9.  * Everyone is permitted to copy and distribute verbatim or modified
  10.  * copies of this license document, and changing it is allowed as long
  11.  * as the name is changed.
  12.  *
  13.  *            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  14.  *   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  15.  *
  16.  *  0. You just DO WHAT THE FUCK YOU WANT TO.
  17.  */
  18.  
  19. /**
  20.  * Class: Request
  21.  *
  22.  */
  23. class Request
  24. {
  25.     private $ch;
  26.     private string $proxyHost;
  27.     private int $proxyPort;
  28.     private string $requestCookie;
  29.  
  30.     /**
  31.      * __construct
  32.      *
  33.      * @param string $proxyHost
  34.      * @param int $proxyPort
  35.      */
  36.     public function __construct(string $proxyHost = '', int $proxyPort = 9050)
  37.     {
  38.         $this->proxyHost = $proxyHost;
  39.         $this->proxyPort = $proxyPort;
  40.         $this->ch = curl_init();
  41.         $this->requestCookie = sys_get_temp_dir() . '/cookie.txt';
  42.     }
  43.  
  44.     /**
  45.      * request
  46.      *
  47.      * @param string $requestUrl
  48.      * @param mixed $requestDatas
  49.      * @param mixed $requestHeaders
  50.      */
  51.     public function request(
  52.         string $requestUrl,
  53.         $requestDatas = null,
  54.         $requestHeaders
  55.     ) {
  56.         $ch = $this->ch;
  57.  
  58.         if ($this->proxyHost && $this->proxyPort) {
  59.             curl_setopt($ch, CURLOPT_PROXY, $this->proxyHost);
  60.             curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxyPort);
  61.             curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
  62.         }
  63.  
  64.         if ($requestDatas) {
  65.             curl_setopt($ch, CURLOPT_POSTFIELDS, $requestDatas);
  66.             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
  67.         } else {
  68.             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  69.         }
  70.  
  71.         if ($requestHeaders) {
  72.             curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
  73.         }
  74.  
  75.         curl_setopt($ch, CURLOPT_URL, $requestUrl);
  76.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  77.         curl_setopt($ch, CURLOPT_COOKIEJAR, $this->requestCookie);
  78.         curl_setopt($ch, CURLOPT_COOKIEFILE, $this->requestCookie);
  79.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  80.         curl_setopt($ch, CURLOPT_HEADER, false);
  81.         curl_setopt($ch, CURLOPT_VERBOSE, false);
  82.         $result = curl_exec($ch);
  83.  
  84.         if (!$result) {
  85.             throw new \Exception(curl_error($ch));
  86.         }
  87.         return $result;
  88.     }
  89.  
  90.     public function __destruct()
  91.     {
  92.         curl_close($this->ch);
  93.     }
  94. }
  95.  
  96. //$app = new Request('127.0.0.1', 9050);
  97. $app = new Request();
  98.  
  99. $gameId = '260343526';
  100. $vCode = '951285';
  101.  
  102. $redeemCodes = [
  103.     '2020SummerCarnival',
  104.     'MissionSuccess',
  105.     'MayYourWishesComeTrue',
  106. ];
  107.  
  108. foreach ($redeemCodes as $redeemCode) {
  109.     $requestDatas = [
  110.         'redeemcode' => $redeemCode,
  111.         'gameid' => $gameId,
  112.         'captcha' => '',
  113.         'vcode' => $vCode,
  114.         'language' => 'en',
  115.     ];
  116.  
  117.     $requestHeaders = [
  118.         'referer: https://m.mobilelegends.com/en/codexchange',
  119.         'origin: https://m.mobilelegends.com',
  120.         'content-type: application/json',
  121.     ];
  122.  
  123.     $requestJsonData = json_encode($requestDatas);
  124.  
  125.     $response = $app->request(
  126.         'https://mapi.mobilelegends.com/api/sendredeem',
  127.         $requestJsonData,
  128.         $requestHeaders
  129.     );
  130.  
  131.     echo 'Code: ', $redeemCode, ' Result: ', $response, PHP_EOL;
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement