อยากถามการเชื่อมต่อกับ TrueWallet โดยใช้ JAVA (JSON) ทำอย่างไรคับ
มันจะไม่ปลอดภัยเอาน่ะ เพราะมันต้อง ใส่ หมายเลขโทรศัพท์ หรือ email และ พาสเวิร์ด
มันควรทำจาก server
Date :
2018-10-10 12:30:32
By :
Chaidhanan
java ไม่มีครับ มีแต่ php curl คงต้องไปดัดแปลงเอาเอง นะครับ
Code (PHP)
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class TrueWalletAPI{
private $username = '????????';// email or phonenumber
private $password = '???????';
private $login_type = 'email';// email or mobile
private $passhash;
//Config TrueWallet ห้ามแก้ไขหากไม่รู้ค่าที่แท้จริง
private $api_signin = "https://api-ewm.truemoney.com/api/v1/signin?&";
private $api_profile = "https://api-ewm.truemoney.com/api/v1/profile/";
private $api_topup = "https://api-ewm.truemoney.com/api/api/v1/topup/mobile/";
private $api_gettran = "https://api-ewm.truemoney.com/api/v1/profile/transactions/history/";
private $api_checktran = "https://api-ewm.truemoney.com/api/v1/profile/activities/";
private $device_os = "android";
private $device_id = "d520d0d12d0d48cb89394905168c6ed5";
private $device_type = "CPH1611";
private $device_version = "6.0.1";
private $app_name = "wallet";
private $app_version = "4.0.1";
private $deviceToken = "fUUbZJ9nwBk:APA91bHHgBBHhP9rqBEon_BtUNz3rLHQ-sYXnezA10PRSWQTwFpMvC9QiFzh-CqPsbWEd6x409ATC5RVsHAfk_-14cSqVdGzhn8iX2K_DiNHvpYfMMIzvFx_YWpYj5OaEzMyIPh3mgtx";
private $mobileTracking = "dJyFzn\/GIq7lrjv2RCsZbphpp0L\/W2+PsOTtOpg352mgWrt4XAEAAA==";
private $token;
public $pf;
public function __construct(){
$this->passhash = sha1($this->username.$this->password);
$a = $this->GetToken();
$j = json_decode($a);
$this->token = $j->data->accessToken;
$this->pf = $this->Profile();
}
public function GetToken(){
$url = $this->api_signin.'device_os='.$this->device_os.'&device_id='.$this->device_id.
'&device_type='.$this->device_type.'&device_version='.$this->device_version.
'&app_name='.$this->app_name.'&app_version='.$this->app_version;
$header = array("Host: api-ewm.truemoney.com","Content-Type: application/json");
$postfield = array(
"username"=>$this->username,
"password"=>$this->passhash,
"type"=>$this->login_type,
"deviceToken"=>$this->deviceToken,
"mobileTracking"=>$this->mobileTracking,
);
$data_string = json_encode($postfield);
return $this->wallet_curl($url,$data_string,$header);
}
public function Profile(){
$url = $this->api_profile.$this->token.'?&device_os=android&device_id='.$this->device_id.
'&device_type='.$this->device_type.'&device_version='.$this->device_version.
'&app_name='.$this->app_name.'&app_version='.$this->app_version;
$header = array("Host: api-ewm.truemoney.com");
$a = $this->wallet_curl($url,false,$header);
return json_decode($a);
}
public function Topup($cashcard){
$url = $this->api_topup.time()."/".$this->token."/cashcard/".$cashcard;
$header = array("Host: api-ewm.truemoney.com");
$a = $this->wallet_curl($url,true,$header);
return json_decode($a);
}
public function getTran($start,$end){
$url = $this->api_gettran.$this->token.'/?startDate='.$start.'&endDate='.$end.'&limit=20&page=1&type=&action=';
$header = array("Host: api-ewm.truemoney.com");
$a=$this->wallet_curl($url,false,$header);
return json_decode($a);
}
public function CheckTran($id){
$url = $this->api_checktran.$id.'/detail/'.$this->token.'?&device_os=android&device_id='.$this->device_id.
'&device_type='.$this->device_type.'&device_version='.$this->device_version.
'&app_name='.$this->app_name.'&app_version='.$this->app_version;
$header = array("Host: api-ewm.truemoney.com");
$a=$this->wallet_curl($url,false,$header);
return json_decode($a);
}
private function wallet_curl($url,$data,$header){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
if($data){
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
}
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_USERAGENT,'okhttp/3.8.0');
$result = curl_exec($ch);
return $result;
}
}
credit: จำลิงค์ไม่ได้แล้วนะครับ เอามาใช้นานแล้ว หาได้ใน google น่ะครับ
จริงๆ ก็เขียนเป็น from html ส่งข้อมูลไปก็ได้ แต่มันจะไม่ปลอดภัย ถ้าให้คนอื่นใช้
เขาทำ api ตัวรับแบบง่ายๆ ไม่มีอะไรมาก
Date :
2018-10-10 16:06:26
By :
Chaidhanan
Load balance : Server 05