Jump to content

PHP ESP Class


Recommended Posts

Looking at the documentation for the api I see PHP examples make use of a class ESP. Is this class publically available?

It would save me a lot of time translating from go.

$the_transport = new \Esp\Transport("", "xmlmc", "dav");
$mc = new \Esp\MethodCall($the_transport);

try
{

 

 

Link to comment
Share on other sites

Further to this how do you get hold of the documentation that's mentioned in regard to Hornbill Development?

For example, I've managed to talk with the api and got some responses, but not sure what I need to pass in order to get what I'm after.

At this stage I'm interested in simple form data to update an asset location/site. So The process I need to go through would seem to be:

session::userLogon - pass userid and password (or maybe the api key let's me skip this?) Take the SessionID

com.hornbill.servicemanager/Asset::searchAssetGlobal - Send the previous SessionID and pass a string as a filter??? This is what I struggle with. Can I just pass an asset name or does it need something more like "h_name like '%search%'"?

session::userLogoff - Send previous SessionID

So this shows it logs me on:

<methodCall service="session" method="userLogon"><params><userId>paulb</userId><password>ODFGDFGGGSDxOg==</password></params></methodCall>

Esp\XmlmcInstStruct Object
(
    [server] => https://eurapi.hornbill.com/charnwoodbc/xmlmc/
    [paramsXml] => paulbODFGDFGGGSDxOg==
    [statusCode] => 
    [timeout] => 30
    [sessionID] => 
    [apiKey] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    [jsonResp] => 
)
* Hostname was NOT found in DNS cache
*   Trying 78.129.173.117...
* Connected to eurapi.hornbill.com (78.129.173.117) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* Server certificate:
* 	 subject: C=GB; ST=Middlesex; L=Ruislip; O=Hornbill Service Management Limited; OU=Marketing; CN=*.hornbill.com
* 	 start date: 2014-10-29 00:00:00 GMT
* 	 expire date: 2017-03-24 23:59:59 GMT
* 	 subjectAltName: eurapi.hornbill.com matched
* 	 issuer: C=US; O=GeoTrust Inc.; CN=GeoTrust SSL CA - G3
* 	 SSL certificate verify ok.
> POST /charnwoodbc/xmlmc/session/ HTTP/1.1
Content-type: text/xmlmc
Authorization: ESP-APIKEY xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Accept: Application/json
User-Agent: GuzzleHttp/6.2.1 curl/7.38.0 PHP/5.6.24-0+deb8u1
Host: eurapi.hornbill.com
headers: text/xmlmc
headers: ESP-APIKEY xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
headers: Application/json
headers: 138
Content-Length: 138

* upload completely sent off: 138 out of 138 bytes
< HTTP/1.1 200 OK
* Server nginx is not blacklisted
< Server: nginx
< Date: Thu, 18 Aug 2016 15:05:44 GMT
< Content-Type: text/json; charset="utf-8"
< Content-Length: 79
< Connection: keep-alive
< Accept-Ranges: bytes
< Cache-Control: no-cache
< Set-Cookie: ESPSessionState=KA59jllmB48qZVhJojMWCsT1dwd1QOj_stURehYxkqgHUZfgwKNa; path=/charnwoodbc
< X-esp-instance: charnwoodbc
< X-esp-service-build-date: 2016-07-12
< X-esp-service-name: Esp.charnwoodbc.ServerService
< X-esp-service-version: 8.0.0.2578
< X-esp-transaction-id: af6468db-8d3d-40eb-b489-9d05293a327b
< X-esp-transaction-perf: t=2016-08-18 15:05:44Z, tt=40.842ms
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< 
* Connection #0 to host eurapi.hornbill.com left intact

Then I try to query for an asset and am not sure what to pass here:

<methodCall service="com.hornbill.servicemanager/Asset" method="searchAssetGlobal"><params><filter>** WHAT TO PUT HERE? **</filter><sessionId>KA59jllmB48qZVhJojMWCsT1dwd1QOj_stURehYxkqgHUZfgwKNa</sessionId></params></methodCall>

Esp\XmlmcInstStruct Object
(
    [server] => https://eurapi.hornbill.com/charnwoodbc/xmlmc/
    [paramsXml] => 3533
    [statusCode] => 200
    [timeout] => 30
    [sessionID] => KA59jllmB48qZVhJojMWCsT1dwd1QOj_stURehYxkqgHUZfgwKNa
    [apiKey] => xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    [jsonResp] => 
)
* Hostname was found in DNS cache
*   Trying 78.129.173.117...
* Connected to eurapi.hornbill.com (78.129.173.117) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* Server certificate:
* 	 subject: C=GB; ST=Middlesex; L=Ruislip; O=Hornbill Service Management Limited; OU=Marketing; CN=*.hornbill.com
* 	 start date: 2014-10-29 00:00:00 GMT
* 	 expire date: 2017-03-24 23:59:59 GMT
* 	 subjectAltName: eurapi.hornbill.com matched
* 	 issuer: C=US; O=GeoTrust Inc.; CN=GeoTrust SSL CA - G3
* 	 SSL certificate verify ok.
> POST /charnwoodbc/xmlmc/com.hornbill.servicemanager/Asset/ HTTP/1.1
Content-type: text/xmlmc
Authorization: ESP-APIKEY xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Accept: Application/json
User-Agent: GuzzleHttp/6.2.1 curl/7.38.0 PHP/5.6.24-0+deb8u1
Host: eurapi.hornbill.com
headers: text/xmlmc
headers: ESP-APIKEY xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
headers: Application/json
headers: 209
Content-Length: 209

* upload completely sent off: 209 out of 209 bytes
< HTTP/1.1 200 OK
* Server nginx is not blacklisted
< Server: nginx
< Date: Thu, 18 Aug 2016 15:05:44 GMT
< Content-Type: text/xmlmc; charset=utf-8
< Content-Length: 226
< Connection: keep-alive
< Accept-Ranges: bytes
< Cache-Control: no-cache
< Set-Cookie: ESPSessionState=; path=/charnwoodbc
< X-esp-instance: charnwoodbc
< X-esp-service-build-date: 2016-07-12
< X-esp-service-name: Esp.charnwoodbc.ServerService
< X-esp-service-version: 8.0.0.2578
< X-esp-transaction-id: 770d0c28-de81-4a98-9707-0554c14e4683
< X-esp-transaction-perf: t=2016-08-18 15:05:44Z, tt=1.235ms
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< 
* Connection #0 to host eurapi.hornbill.com left intact

Why does it set the ESPSessionState to empty here?

Link to comment
Share on other sites

Hi there,

You might want to edit you post and remove any passwords, in regards to the API documentation you can use the following URL

https://eurapi.hornbill.com/charnwoodbc/xmlmc/

As for the ESP PHP Library we are working on publishing our API libraries on https://github.com/hornbill/ as soon as we have something available for PHP i will post a response.

Kind Regards

Trevor Killick

Link to comment
Share on other sites

The passwords in the post are not real ;)

I have managed to figure this out and have rolled my own php library that gets me the responses needed.

It was more straight forward than I thought, but a simple mistake can tie things up for quite a while.

$api->SetParam('filter', 'ASSETSTRING');
$api->Invoke('apps/com.hornbill.servicemanager/Asset', 'searchAssetGlobal');

My mistake was omitting the apps/ part of the service.

The filter string itself is nothing but the string you'd type in to search in the UI.

Also as I hoped, as long as the API key is set then no user logon is required. Just set params and call invoke.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...