开发WHMCS时,数据库中不会显示$ request结果

时间:2018-08-28 05:13:41

标签: php python-requests whmcs

我在开发WHMCS时添加了ClientAdd钩子:

add_hook('ClientAdd', 1, function($vars){

    logActivity('client add -liaomalin2');
    // phonenumber, username
    $params = array(
        "whmcs_tblclients_id" => $vars['userid'],
        "email" => $vars['email'],
        "username" => $vars['email'],
        "phone" => $vars['phonenumber'],
        "password" => $vars["password"]
    );

    // QICLOUD_API_USER_REGISTER
    $request = Requests::get('http://xxx.xxx.xxx.xxx:8000/api/groups/list/', array(), null); //

    logActivity($params . '$params-liaomalin2');

    logActivity($request . '$request-liaomalin2');

});

但是在数据库中,记录活动:

enter image description here

您看到$request那里什么都没有,$params是一个数组。错误在哪里?

我在另一个演示项目中尝试了代码:

$request = Requests::get('http://xxx.xxx.xxx.xxx:8000/api/groups/list/', array(), null); 

$request是一个对象:

object(Requests_Response)#4 (10) {
  ["body"]=>
  string(449) "[{"id":2,"name":"group02","permissions":[34,35,36,31,32,33,1,2,22,23,24]},{"id":1,"name":"staff","permissions":[1,2,3]},{"id":7,"name":"aa","permissions":[]},{"id":5,"name":"a","permissions":[34,35,36]},{"id":3,"name":"a","permissions":[13]},{"id":6,"name":"test1","permissions":[]},{"id":4,"name":"s","permissions":[]},{"id":8,"name":"","permissions":[]},{"id":9,"name":"x","permissions":[]}]"
  ["raw"]=>
  string(655) "HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
Allow: GET, HEAD, OPTIONS
Content-Length: 449
Content-Type: application/json
Vary: Accept, Cookie
Date: Tue, 28 Aug 2018 04:25:38 GMT
Connection: close

[{"id":2,"name":"group02","permissions":[34,35,36,31,32,33,1,2,22,23,24]},{"id":1,"name":"staff","permissions":[1,2,3]},{"id":7,"name":"s","permissions":[]},{"id":5,"name":"s","permissions":[34,35,36]},{"id":3,"name":"s","permissions":[13]},{"id":6,"name":"test1","permissions":[]},{"id":4,"name":"a","permissions":[]},{"id":8,"name":"a","permissions":[]},{"id":9,"name":"a","permissions":[]}]"
  ["headers"]=>
  object(Requests_Response_Headers)#5 (1) {
    ["data":protected]=>
    array(6) {
      ["x-frame-options"]=>
      array(1) {
        [0]=>
        string(10) "SAMEORIGIN"
      }
      ["allow"]=>
      array(1) {
        [0]=>
        string(18) "GET, HEAD, OPTIONS"
      }
      ["content-length"]=>
      array(1) {
        [0]=>
        string(3) "449"
      }
      ["content-type"]=>
      array(1) {
        [0]=>
        string(16) "application/json"
      }
      ["vary"]=>
      array(1) {
        [0]=>
        string(14) "Accept, Cookie"
      }
      ["date"]=>
      array(1) {
        [0]=>
        string(29) "Tue, 28 Aug 2018 04:25:38 GMT"
      }
    }
  }
  ["status_code"]=>
  int(200)
  ["protocol_version"]=>
  float(1.1)
  ["success"]=>
  bool(true)
  ["redirects"]=>
  int(0)
  ["url"]=>
  string(42) "http://xxxx:8000/api/groups/list/"
  ["history"]=>
  array(0) {
  }
  ["cookies"]=>
  object(Requests_Cookie_Jar)#2 (1) {
    ["cookies":protected]=>
    array(0) {
    }
  }
}

为什么logActivity什么都不是?

0 个答案:

没有答案