Ask Your Question
0

Resource id #2

asked 2013-11-27 04:17:40 -0500

harish gravatar image

updated 2013-11-27 04:21:44 -0500

Hi

I'm getting error while connecting horizen with API.

Resource id #2 ApiRequestException Object ( [message:protected] => Failed to connect to 0.0.0.123: Invalid argument [string:Exception:private] => [code:protected] => 7 [file:protected] => /home/racknapz/public_html/admin/test/openstack/plesk.php [line:protected] => 104 [trace:Exception:private] => Array ( [0] => Array ( [file] => /home/racknapz/public_html/admin/test/openstack/openstack.php [line] => 23 [function] => sendRequest [args] => Array ( [0] => Resource id #2 [1] => tenantId=32c4101bce274e0ea49180d387a2f907 ) ) ) [previous:Exception:private] => )

For your reference I'm sending you link :

https://manage.znetlive.com/admin/test/openstack/openstack.php

Please help me.

Thanks

Harish

edit retag flag offensive close merge delete

Comments

link is not accessible. Also this may be related to other issue you raised. I have responded to other issue. It is better to fix other issue before getting into this. Looks both are related.

dheeru gravatar imagedheeru ( 2013-11-27 04:43:17 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-11-29 05:27:20 -0500

harish gravatar image

Hi Dheeru

deeptanshu will coordinate with your for your require details. Meanwhile i'm sending you script detail which i'm using for connection.

/**

  • Reports error during API RPC request

    / class ApiRequestException extends Exception {} /*

  • Returns DOM object representing request for information about all available domains
  • @return DOMDocument / /*
  • Reports error during API RPC request */ function parseResponse($response_string) { $xml = new SimpleXMLElement($response_string);

    if (!is_a($xml, 'SimpleXMLElement'))

         throw new ApiRequestException("Cannot parse server response: {$response_string}");
    

    return $xml; }

function curlInit($login, $password,$host) { $curl = curl_init();

  curl_setopt($curl, CURLOPT_URL, $host);

  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

  curl_setopt($curl, CURLOPT_POST,           true);

  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

  curl_setopt($curl, CURLOPT_HTTPHEADER,

         array("HTTP_AUTH_LOGIN: {$login}",

                "HTTP_AUTH_PASSWD: {$password}",

                "HTTP_PRETTY_PRINT: TRUE",

                "Content-Type: application/json'")
  );

  return $curl;

}

/**

  • Performs a Panel API request, returns raw API response text

  • @return string

  • @throws ApiRequestException

    */

function sendRequest($curl, $packet)

{

  curl_setopt($curl, CURLOPT_POSTFIELDS, $packet);

  $result = curl_exec($curl);

  if (curl_errno($curl)) {

         $errmsg  = curl_error($curl);

         $errcode = curl_errno($curl);

         curl_close($curl);

         throw new ApiRequestException($errmsg, $errcode);

  }

  curl_close($curl);

  return $result;

}

function checkResponse(SimpleXMLElement $response)

{

  $resultNode = $response->customer->get->result;

  // check if request was successful

  if ('error' == (string)$resultNode->status)

         throw new ApiRequestException("The Panel API returned an error: " . (string)$resultNode->result->errtext);

}

////*******************************///////

$packet='tenantId=32c4101bce274e0ea49180d387a2f907'; $host = 'http://103.247.97.1:5000/v2.0'; $password = 'znet@123'; $login = 'admin';

$curl = curlInit($host, $login, $password); try {

 print_r($curl);

 echo '<br />';

 $response = sendRequest($curl, $packet);

print_r($response);

} catch (ApiRequestException $e) { print_r($e); }

?>

Please check and update me.

Thanks

Harish

edit flag offensive delete link more

Comments

Hi dheeru, Please update me and if possible provide me your email id. Thanks Harish

harish gravatar imageharish ( 2013-12-01 23:40:42 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

2 followers

Stats

Asked: 2013-11-27 04:17:40 -0500

Seen: 1,257 times

Last updated: Nov 29 '13