From 9610c5ca9482cf5388fc889bb84c5e86736c6606 Mon Sep 17 00:00:00 2001 From: benyarat Date: Wed, 19 Nov 2014 18:28:51 +0700 Subject: [PATCH 1/2] create index.php check if user is exist function --- index.php | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 index.php diff --git a/index.php b/index.php new file mode 100644 index 0000000..7efccd8 --- /dev/null +++ b/index.php @@ -0,0 +1,76 @@ + + + E-mail + User Id + Status + + + '.$recipient.' + '.$data['userid'].' + '.$data['status'].' + + '; + + $accountids = ""; + if(is_array($data['accountid']) && count($data['accountid'])>0) + { + $accountids .= ' +
+ + + + '; + + foreach ($data['accountid'] as $key => $value) + { + $accountids .= ' + + + '; + } + + $accountids .= '
Account Id
'.$value.'
'; + } + + echo $user; + echo $accountids; + } +} +?> From b5dfdfcd4cc7af281c6fb0fc41a8a38f7a363e08 Mon Sep 17 00:00:00 2001 From: benyarat Date: Thu, 20 Nov 2014 00:18:38 +0700 Subject: [PATCH 2/2] Update index.php Convert previous version to be a class --- index.php | 188 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 121 insertions(+), 67 deletions(-) diff --git a/index.php b/index.php index 7efccd8..3cf66bc 100644 --- a/index.php +++ b/index.php @@ -1,76 +1,130 @@ -user; + $request['password'] = $this->pass; + + $ch = curl_init($this->url); + $opts[CURLOPT_POST] = true; + $opts[CURLOPT_POSTFIELDS] = http_build_query($request); + $opts[CURLOPT_RETURNTRANSFER] = true; + curl_setopt_array($ch,$opts); + $jsonResponse = curl_exec($ch); + $arrResponse = json_decode($jsonResponse, 1); + + if($arrResponse['status']===true) + { + $this->loginId = $arrResponse['data']['loginid']; + return true; + } + else + return false; + } + + /** + * Fucntion that check if user is exist or not + * @param array $recipient + * @return json + */ + public function checkUser($recipient) + { + $request['act'] = 'usercheck'; + $request['loginid'] = $this->loginId; + $request['email'] = $recipient['email']; + $request['mobile'] = $recipient['mobile']; + $request['country'] = $recipient['country']; + + $ch = curl_init($this->url); + $opts[CURLOPT_POST] = true; + $opts[CURLOPT_POSTFIELDS] = http_build_query($request); + $opts[CURLOPT_RETURNTRANSFER] = true; + curl_setopt_array($ch,$opts); + $jsonResponse = curl_exec($ch); + $arrResponse = json_decode($jsonResponse, 1); + + return $arrResponse; + } + +} - $ch = curl_init('http://txfunds.uat.ipayoptions.com/api.php'); - $opts[CURLOPT_POST] = true; - $opts[CURLOPT_POSTFIELDS] = http_build_query($request); - $opts[CURLOPT_RETURNTRANSFER] = true; - curl_setopt_array($ch,$opts); - $response = curl_exec($ch); - $response = json_decode($response,1); - if($response['status']==1) - { - $data = $response['data']; - $user = ' - - - - - - - - - - - -
E-mailUser IdStatus
'.$recipient.''.$data['userid'].''.$data['status'].'
'; +//requires parames for recipient +$recipient = array( + 'email' => 'test@ipayoptions.com', + 'mobile' => '1221212121112', + 'country' => 'AU' +); - $accountids = ""; - if(is_array($data['accountid']) && count($data['accountid'])>0) - { - $accountids .= ' -
- - - - '; +$obj = new txtFunds(); +$userStatus = $obj->login(); +if($userStatus===true) +{ + $recipientInfo = $obj->checkUser($recipient); + if($recipientInfo['status']===true) + { + $data = $recipientInfo['data']; + $user = ' +
Account Id
+ + + + + + + + + + +
User IdE-mailStatus
'.$data['userid'].''.$recipient['email'].''.$data['status'].'
'; - foreach ($data['accountid'] as $key => $value) - { - $accountids .= ' - - '.$value.' - '; - } + $accountids = ''; + if(is_array($data['accountid']) && count($data['accountid'])>0) + { + $accountids .= ' +
+ + + + '; - $accountids .= '
Account Id
'; - } + foreach ($data['accountid'] as $key => $value) + { + $accountids .= ' + + '.$value.' + '; + } - echo $user; - echo $accountids; - } + $accountids .= ''; + } + } } ?> + + + + + + + + + + +