Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function wf_createAbonent($accountname, $parentId, $cf_918)
- {
- $billingAPIAddr = 'http://185.108.208.71:8082/rest_api/v2';
- $billingMethod = 'Abonents/';
- $arg1 = array(
- 'name' => $accountname,
- 'parent_id' => $parentId,
- 'contract_number' => $cf_918
- );
- $postData = array('method1' => 'objects.create', 'arg1' => json_encode($arg1));
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $billingAPIAddr.'/'.$billingMethod);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postData));
- $preRes = curl_exec($curl);
- $res = json_decode($preRes, true);
- curl_close($curl);
- if (!empty($res['error']) && empty($res['result']['pk'])) {
- return false;
- }
- return $res;
- }
- function wf_createUser($pk, $cf_918)
- {
- $billingAPIAddr = 'http://185.108.208.71:8082/rest_api/v2';
- $billingMethod = 'Users/';
- $arg1 = array(
- 'abonent_id' => $pk,
- 'login' => (int)$cf_918
- );
- $postData = array('method1' => 'objects.create', 'arg1' => json_encode($arg1));
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $billingAPIAddr.'/'.$billingMethod);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postData));
- $preRes = curl_exec($curl);
- $res = json_decode($preRes, true);
- curl_close($curl);
- if (!empty($res['error'])) {
- return false;
- }
- return $res;
- }
- function wf_getAbonentPK($contract_number)
- {
- $billingAPIAddr = 'http://185.108.208.71:8082/rest_api/v2';
- $billingMethod = 'Abonents/';
- $arg1 = array(
- 'contract_number' => $contract_number
- );
- $fields = array('pk');
- $postData = array('method1' => 'objects.get', 'arg1' => json_encode($arg1), 'fields' => json_encode($fields));
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $billingAPIAddr.'/'.$billingMethod);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postData));
- $preRes = curl_exec($curl);
- $res = json_decode($preRes, true);
- curl_close($curl);
- if (!empty($res['error'])) {
- return false;
- }
- return $res['result']['pk'];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement