Jump to content

Rick_F

New Member
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Rick_F

  • Rank
    Junior Member
  1. Hello, I am trying to develop a provisioning module for WHMCS. I am using curl in order to communicate with a remote API. I am currently using this code function provisioningmodule_create_login(array $params) { try { require('login_module.php'); $curl = curl_init(); curl_setopt($curl, CURLOPT_COOKIEJAR, tempnam('/tmp', 'CURLCOOKIE')); $responseLogin = login($curl); $responseCreateDomain = createDomain($curl, 'test.com', 2048, 1); curl_close($curl); } catch (Exception $e) { // Record the error in WHMCS's module log. logModuleCall( 'provisioningmodule', __FUNCTION__, $params, $e->getMessage(), $e->getTraceAsString() ); return $e->getMessage(); } return 'success'; } File login_module.php function login($curl) { global $url; global $pass; global $user; curl_setopt($curl, CURLOPT_URL, $url . '/login'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, array( 'username' => $user, 'password' => $pass, )); curl_setopt($curl, CURLOPT_VERBOSE, true); $errStream = fopen('php://temp', 'w+'); curl_setopt($curl, CURLOPT_STDERR, $errStream); $response = curl_exec($curl); rewind($errStream); $verboseLog = stream_get_contents($errStream); logModuleCall( 'provisioningmodule', 'login_raw', $verboseLog, 'test', 'test' ); $responseJSON = json_decode($response, TRUE); return $responseJSON; }; Curl is not working. It even doesn't create a cookie in /tmp But my main issue is logging. I only get the last line of the curl output in the module log which is "* Closing connection -1". What am I doing wrong? PHP doesn't error anything. Already tried setting error_log path (which is visible in the whmcs php info). Has anyone had this problem?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated