What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

php call to page request

Votes:

0

I have this script:

$server = "https://server.com";
$fileType = "/api/table.json?";
$uName = "bart";
$pWord = "XXXXXX";
$url = "content=devices&id=2672&output=xml&columns=group,name&username=" . $uName . "&userhash=" . $pWord;

$request = $server . $fileType . $url;
echo file_get_contents($request);

when i call it via php -f file.php I get this error:

failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized

if i load the url into browser, it works as expected. any thoughts?

api php prtg

Created on Jul 1, 2014 5:05:03 PM

Last change on Jul 1, 2014 5:41:59 PM by  Konstantin Wolff [Paessler Support]



2 Replies

Votes:

0

Hi,
in your variable $url please try using either the parameter passhash or password but not userhash. Corrected version below:

$url = "content=devices&id=2672&output=xml&columns=group,name&username=" . $uName . "&passhash=" . $pWord;

(use password as parameter if you are using the password to authenticate)
Does that work?

Created on Jul 1, 2014 5:44:42 PM by  Konstantin Wolff [Paessler Support]



Votes:

0

passhash worked. thank you.

Created on Jul 1, 2014 5:51:14 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.