Retrieve an affiliate by code
Request Example
<?php function callRPC($Request, $hostUrl, $Debug = true) { $curl = curl_init($hostUrl); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_SSLVERSION, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Accept: application/json', 'Cookie: XDEBUG_SESSION=PHPSTORM', )); $RequestString = json_encode($Request); curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString); if ($Debug) { var_dump($RequestString); } $ResponseString = curl_exec($curl); if ($Debug) { var_dump($ResponseString); } if (!empty($ResponseString)) { // var_dump($ResponseString); $Response = json_decode($ResponseString); if (isset($Response->result)) { return $Response->result; } var_dump($Response); if (!is_null($Response->error)) { var_dump($Request->method, $Response->error); } } else { return null; } } $apiVersion = '6.0'; $host = "http://api.sandbox34.avangate.local/rpc/" . $apiVersion . "/"; $merchantCode = "lucian"; $key = "SECRET_KEY"; $date = gmdate('Y-m-d H:i:s'); $string = strlen($merchantCode) . $merchantCode . strlen($date) . $date; $hash = hash_hmac('md5', $string, $key); $i = 1; // counter for api calls // call login $jsonRpcRequest = new stdClass(); $jsonRpcRequest->jsonrpc = '2.0'; $jsonRpcRequest->method = 'login'; $jsonRpcRequest->params = array($merchantCode, $date, $hash); $jsonRpcRequest->id = $i++; $sessionID = callRPC($jsonRpcRequest, $host); var_dump($sessionID); $affiliateId = "79396127BA"; // Active: // 1295 - 964CF2AF42 // 11541 - E4B69882C2 // 12951 - E8A1DB473C // 12950 - 44857BFE94 // Pending: // 13639 - F56BCF1E2E // Rejected // 65602 - 79396127BA $jsonRpcRequest = new stdClass(); $jsonRpcRequest->jsonrpc = '2.0'; $jsonRpcRequest->method = 'getAffiliate'; $jsonRpcRequest->params = array($sessionID, $affiliateId); $jsonRpcRequest->id = $i++; echo "\nRESPONSE: \n\n"; $getAffiliate = callRPC($jsonRpcRequest, $host, false); print_r(json_encode($getAffiliate));