-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
I use curl exec is ok , but use api-clients call will return HTTP/1.1 400 Bad Request error...
who can help me....
[root@weather IPAM]# curl -X GET http://ipam.xxx.xxx.xxx/api/ipam/user/ --header 'token:h==kas7bR$eX__2TgHKyW0oO'
{"code":200,"success":true,"data":{"expires":"2018-04-14 20:24:39"},"time":0.043}
[root@IPAM]# php example.php
* About to connect() to ipam.xxx.xxx.xxx port 80 (#0)
* Trying 127.0.0.1...
* Connected to ipam.xxx.xxx.xxx (127.0.0.1) port 80 (#0)
> POST /api/ipam/user/ HTTP/1.1
User-Agent: phpipam-api php class
Host: ipam.xxx.xxx.xxx
Accept: */*
Authorization: Basic YXBpOm5jaHVjY25ldDIxNw==
Content-Length: -1
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue
< HTTP/1.1 400 Bad Request
< Date: Sat, 14 Apr 2018 06:26:55 GMT
< Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips mod_fcgid/2.3.9 PHP/5.6.33
< Connection: close
< Content-Type: text/html; charset=iso-8859-1
<
* Closing connection 0
<?php
#api-config.php
# set error reporting
error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT);
# api params
$api_url = "http://ipam.xxx.xxx.xxx/api/"; // server url
$api_app_id = "ipam"; // application id
$api_key = false; // api key - only for encrypted methods, otherwise must be false
# set username / password for authentication, not needed for encrypted communications
$api_username = "api";
$api_password = "testpassword";
# save token or not ?
# false => dont save, check each time
# filename => will save token to filename provided
$token_file = false;
# set result format json/object/array/xml
$result_format = "json";
?>
<?php
#example.php
# include config file and api client class file
require("api-config.php");
require("class.phpipam-api.php");
# init object with settings from
$API = new phpipam_api_client ($api_url, $api_app_id, $api_key, $api_username, $api_password, $result_format);
$API->set_debug (true);
$API->execute ("GET", "user", array(), array(), $token_file);
# get result
$result = $API->get_result();
# print result
print_r($response_headers);
// print_r($result);
print_r(json_decode($result, true));
?>
Metadata
Metadata
Assignees
Labels
No labels