showbw() ---Fatal error: Uncaught exception 'Exception' with message 'curl_exec threw error "

conseld

Member
Feb 16, 2007
5
0
151
Hello guys, I updated my WHM 11.50.0.10 yesterday, I use Xmlapi API to manage my bills, gave error band (Traffic) use the showbw () function.
I do not know what happened now no longer works. See the error!

Code:
Fatal error: Uncaught exception 'Exception' with message 'curl_exec threw error "" for hxxps://189.113.xxx.xx:2087/xml-api/showbw?' in /home/controle/public_html/conseld/Servidor/xmlapi.php:759 Stack trace: #0 /home/controle/public_html/conseld/Servidor/xmlapi.php(676): xmlapi->curl_query('hxxps://189.113...', '', 'Authorization: ...') #1 /home/controle/public_html/conseld/Servidor/xmlapi.php(2136): xmlapi->xmlapi_query('showbw') #2 /home/controle/public_html/conseld/InformacaoConta/informacao.php(175): xmlapi->showbw() #3 /home/controle/public_html/conseld/ListarConta/fullTab.php(175): include_once('/home/controle/...') #4 {main} thrown in /home/controle/public_html/conseld/Servidor/xmlapi.php on line 7
Code:
[B]Error line (759) file -->xmlapi.php[/B]
[U][I]throw new Exception("curl_exec threw error \"" . curl_error($curl) . "\" for " . $url . "?" . $postdata );[/I][/U]

[I]  private function curl_query( $url, $postdata, $authstr )
  {
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
  // Return contents of transfer on curl_exec
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  // Allow self-signed certs
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
  // Set the URL
  curl_setopt($curl, CURLOPT_URL, $url);
  // Increase buffer size to avoid "funny output" exception
  curl_setopt($curl, CURLOPT_BUFFERSIZE, 131072);

  // Pass authentication header
  $header[0] =$authstr .
  "Content-Type: application/x-www-form-urlencoded\r\n" .
  "Content-Length: " . strlen($postdata) . "\r\n" . "\r\n" . $postdata;

  curl_setopt($curl, CURLOPT_HTTPHEADER, $header);

  //curl_setopt($curl, CURLOPT_POST, 0);
      curl_setopt($curl, CURLOPT_POST, 1);

  $result = curl_exec($curl);
  if ($result == false) {
  [B]throw new Exception("curl_exec threw error \"" . curl_error($curl) . "\" for " . $url . "?" . $postdata )[/B];
  }
  curl_close($curl);

  return $result;
  }[/I]

[B]Error line (2136) file -->xmlapi.php[/B]
[U][I]return $this->xmlapi_query('showbw', $args);[/I][/U]

[I] public function showbw($args = null)
  {
  if (is_array($args)) {
  [B]return $this->xmlapi_query('showbw', $args);[/B]
  }

  return $this->xmlapi_query('showbw');
  }

  public function nvset($key, $value)
  {
  if (!isset($key) || !isset($value)) {
  error_log("nvset requires that key and value are passed to it");

  return false;
  }

  return $this->xmlapi_query('nvset', array('key' => $key, 'value' => $value));
  }[/I]

[B]Error line (676) file -->xmlapi.php[/B]
[U][I]$response = $this->curl_query($url, $args, $authstr);[/I][/U]

$response = NULL;
  if ($this->http_client == 'curl') {
  $response = $this->curl_query($url, $args, $authstr);
  } elseif ($this->http_client == 'fopen') {
  $response = $this->fopen_query($url, $args, $authstr);
  }

[B]Error line informacao.php(175): xmlapi->showbw()[/B]
[U][I]$xml1 = simplexml_load_string($accounts1);[/I][/U]

$accounts1 = $xmlapi->showbw();
$xml1 = simplexml_load_string($accounts1);
$expression1 = sprintf("/*/bandwidth/acct[contains(user, '".$_SESSION["gravaUser"]."')]", $_SESSION["gravaUser"]);
$result1 = $xml1->xpath($expression1);
Was running after this update is not working. Could someone help me
 
Last edited by a moderator:

conseld

Member
Feb 16, 2007
5
0
151
https://documentation.cpanel.net/display/SDK/WHM+API+1+Functions+-+showbw

I'm trying to use this API Cpanel

Code:
$trafic = array($_SESSION["gravaUser"]);
$traficEx = $xmlapi->api1_query($_SESSION["gravaUser"],"Showbw","showbw", $trafic);
print_r (simplexml_load_string($traficEx));


SimpleXMLElement Object ( [module] => Showbw [func] => showbw [type] => event [source] => module [apiversion] => 1 [data] => SimpleXMLElement Object ( [result] => SimpleXMLElement Object ( ) ) [event] => SimpleXMLElement Object ( [reason] => Showbw::showbw(user) failed: Can't use string ("") as a subroutine ref while "strict refs" in use at cpanel.pl line 1740. [result] => 0 ) [error] => Showbw::showbw(user) failed: Can't use string ("") as a subroutine ref while "strict refs" in use at cpanel.pl line 1740. )
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,226
463
Hello :)

Are you still experiencing this issue? Internal case number 191833 addressed an issue with the display of bandwidth usage in cPanel version 11.50.0.12.

Thank you.