473,408 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Axis camera and PHP

I have to send a restart command to an IP camera from a PHP script. The
command is as follow:

http://192.168.1.5/axis-cgi/admin/restart.cgi

where 192.168.1.5 is the address of the camera.

In PHP, my idea was to open a socket connection and send the command, with
the following code:

$host="192.168.1.5" ;
$target="/axis-cgi/admin/restart.cgi" ;
$port=80 ;
$timeout=60;
$br="\r\n" ;
$usarname="root";
$password="password_root";
$sk=fsockopen($host,$port,$errnum,$errstr,$timeout ) ;
if(!is_resource($sk)){
exit("Connection failed: ".$errnum." ".$errstr) ;
}
else{
$headers = "GET ".$target." HTTP/1.1".$br ;
$headers.="Accept: */*".$br ;
$headers.="Accept-Language: it".$br ;
$headers.="Host: ".$host.$br ;
$headers.="Authorization: Basic root:password_root".$br.$br;
fputs($sk,$headers) ;

When printing $sk I see the error message

401 Unauthorized
You client does not have permission to get URL /axis-cgi/admin/restart.cgi
from this server

Seems there is something wrong with authentication.

Any idea ?
Is there somebody who uses PHP with Axis camera ? How do you send API
commands to the camera ?
Thank you for your help.

Stefano

Aug 12 '07 #1
2 7598
Stefano wrote:
So, after curl_init(), using the function :

curl_setopt($curl, CURLOPT_HTTPAUTH, 'username:password');

I get the same error message as before: 401 Unauthorized.
Right. It was my failure. Better to read my posting before send.
Yesterday i used it like my example but with PROXY* Paramater. worry? :-)
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

Seems that username:password is not accepted as CURLOPT_HTTPAUTH set value.
In that case where should I specify login and password ?
The fast and bad way is URL-injection like this:
http://username:pa******@example.com/...

The other and better way is to change youre code at line:
$headers.="Authorization: Basic root:password_root".$br.$br;

to:
$headers .= 'Authorization: Basic '
. base64_encode('root:password_root') . $br . $br);

The RFC says username:password must be Base64 encoded.

By the way: A good PHP-Library for doing something more with
http/ftp/... (by a easy way) is Snoopy.
http://sourceforge.net hosts it.

--
_,
_(_p Ulf [Kado] Kadner
\<_)
^^
Aug 12 '07 #2
The other and better way is to change youre code at line:
$headers.="Authorization: Basic root:password_root".$br.$br;

to:
$headers .= 'Authorization: Basic '
. base64_encode('root:password_root') . $br . $br);
YYYEEEESSSSS !!!!
It works now !

To be honest, I tryed the function base64_encode() before but colon was
outside base64_encode.

Thank you very much Ulf. I was working around that problem since last week.

Regards.
Stefano

Aug 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dave Keays | last post by:
I am setting-up an experimental web service using Apache Axis but I'm having problems. AXIS can't find a library that I've verified exists on my computer and that CLASSPATH points to it. I'm using...
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
3
by: Brad Rogers | last post by:
Ive got a project needing to establish a video stream from a camera connected to a USB port. Is there an established way to call out a camera connection dialog box and assign the stream to the...
2
by: Stupid48 | last post by:
I have this Pentax Optio camera and I want to access it via vb.net. I would like to write something where I can snap the picture from the application and it automatically acquires the image from...
4
by: nawrin22 | last post by:
hi.. I am a niwebie in 'AXIS' . but i had correctly installed it without any problem with the help of 'apache.axis.install.pdf' and also tested the examples under 'samples\userguide' directoy...
3
by: Jeremy Chapman | last post by:
I've writtin a very simple web service in axis which returns an array of classes. I consume it in a .net app. When receiving the response, my .net app generates an error "Cannot assign object...
0
by: TraceyAnnison | last post by:
I wonder if you can help me - I'm new to this, and working in a project that has already been configured to work with Axis. We have a Java project built with the Spring framework, in order to...
0
by: princy | last post by:
hi, I am using vlc 0.8.6d to connect Axis 210 camera when enabling "anonymous viewer" in the camera interface the rtsp request given below is working fine The rtsp request is : ...
0
by: Just_a_fan | last post by:
Some folks have searched, from time to time, for a dual axis MSChart with different scales on the two Y axes. The sample, extracted from running code I wrote, produces a graph with MSChart (VB9)...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.