Advertisement
Guest User

Untitled

a guest
Mar 28th, 2019
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.21 KB | None | 0 0
  1. #include "_httpRequest.au3"
  2. $user = 'test'
  3. $pass = '123'
  4. $form = '{"username":"'& $user &'","password":"'& $pass &'"}'
  5. $request = _httpRequest(2, 'https://web.daily.airpay.vn/core/get_csrf/')
  6. $cookie = _getCookie()
  7. $TOKEN = StringRegExp($cookie, 'csrftoken=(.*?);', 1)
  8. If not @error Then
  9.     $TOKEN = $TOKEN[0]
  10. Else
  11.     MsgBox(0,'', 'lấy token thất bại')
  12.     Exit
  13. EndIf
  14. $request = _httpRequest(2, 'https://web.daily.airpay.vn/core/login/',$form,'','','X-CSRFToken: '& $TOKEN &'|Content-Type: application/json;charset=UTF-8')
  15. If StringInStr($request, 'error: 0') Then
  16.     _httpRequest_Msgbox(0, 'Thành công', 'Đăng nhập thành công')
  17. Else
  18.     $error = StringRegExp($request, '"error_message": "(.*?)"', 3)[0]
  19.     _httpRequest_Msgbox(0, 'Thất bại', _Decode($error))
  20. EndIf
  21.  
  22.  
  23.  
  24. Func _Decode($string)
  25.     $string = StringReplace($string, "\/", "/")
  26.     If StringLen($string) <= 0 Then Return ""
  27.     Local $proc
  28.     For $String_Count = 1 To StringLen($string)
  29.         $proc = StringMid($string, $String_Count, 2)
  30.         If $proc = '\u' Then
  31.             $proc1 = ChrW('0x' & StringMid($string, $String_Count + 2, 4))
  32.             $string = StringReplace($string, StringMid($string, $String_Count, 6), $proc1)
  33.         EndIf
  34.     Next
  35.     Return $string
  36. EndFunc   ;==>_Decode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement