harish's profile - activity

2017-08-02 21:13:03 -0600 received badge  Famous Question (source)
2014-11-27 06:52:51 -0600 received badge  Famous Question (source)
2014-11-27 06:52:51 -0600 received badge  Notable Question (source)
2014-11-27 06:52:51 -0600 received badge  Popular Question (source)
2014-09-17 06:43:40 -0600 received badge  Notable Question (source)
2014-07-03 05:16:03 -0600 received badge  Taxonomist
2014-06-13 22:44:23 -0600 received badge  Famous Question (source)
2014-06-13 22:44:23 -0600 received badge  Notable Question (source)
2014-02-19 06:52:57 -0600 received badge  Popular Question (source)
2013-12-16 06:15:44 -0600 received badge  Popular Question (source)
2013-12-06 00:21:52 -0600 answered a question error while connecting from API

Hi,

Now issue resolved.

2013-12-04 03:33:23 -0600 asked a question error while connecting from API

Hi

I'm using curl command in php to connect horizon. you can check the error with given link.

http://znetrocks.com/admin/test/openstack/open_stack_2.php

and the code is given below.

$request = ' <auth xmlns="http://103.247.97.1:5000/v2.0/tokens" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <passwordcredentials password="xyz" username="xyz"> </passwordcredentials></auth>';

// Create Headers //$header[] = "Host: http://103.247.97.1:5000/v2.0/tokens%22 (http://103.247.97.1:5000/v2.0/tokens") ; $header[] = "Content-type: text/xml"; //$header[] = "Content-length: ".strlen($request) . "\r\n"; $header[] = $request;

// Send using CURL $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, "http://103.247.97.1:5000/v2.0/tokens"); // URL to post curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); // return into a variable curl_setopt( $ch, CURLOPT_HTTPHEADER, $header ); // headers from above curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$request);

$result = curl_exec( $ch ); // runs the post print_r($result); curl_close($ch);

?>

2013-12-01 23:40:42 -0600 commented answer Resource id #2

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

2013-11-29 05:27:20 -0600 answered a question Resource id #2

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

2013-11-27 04:21:44 -0600 received badge  Editor (source)
2013-11-27 04:17:40 -0600 asked a question Resource id #2

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

2013-11-25 05:37:08 -0600 asked a question Curl to request to get tokens returns Unauthorized error

Hi

I'm trying below given API to connect horizon.

curl -k -X 'POST' -v http://103.247.97.1:5000/v2.0/tokens -d '{"auth":{"passwordCredentials":{"username": "xyz", "password":"abc"}, "tenantId":"1"}}' -H 'Content-type: application/json'

but getting error :

  • About to connect() to 103.247.97.1 port 5000 (#0)
  • Trying 103.247.97.1... connected
  • Connected to 103.247.97.1 (103.247.97.1) port 5000 (#0) > POST /v2.0/tokens HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: 103.247.97.1:5000 > Accept: / > Content-type: application/json > Content-Length: 124 > < HTTP/1.1 401 Unauthorized < Vary: X-Auth-Token < Content-Type: application/json < Content-Length: 114 < Date: Mon, 25 Nov 2013 11:31:40 GMT <
  • Connection #0 to host 103.247.97.1 left intact
  • Closing connection #0 {"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Unauthorized"}}

Please help me out.

Thanks

Harish