Quicklinks
ActiveSocket provides an easy-to-use development interface to a variety of IP protocols. By using ActiveSocket, you can very easily create or enhance applications with network features.
ActiveSocket features the following: DNS, FTP, HTTP, HTTPs, ICMP Ping, IP-to-Country, MSN, NTP, RSH, SCP, SFTP, SNMP v1/v2c (Get, GetNext, Set), SNMP Traps, SNMP MIB, SSH, TCP, Telnet, TFTP, UDP, Telnet, Wake-On-LAN and more.
HTTP Get and HTTP Post can be well integrated into PHP environments. This document describes how the ActiveSocket Http object can be integrated into PHP projects.
The most important functions of the Http object are:
Download ActiveSocket from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
First, create a new directory on the IIS Server's file system. This directory will hold the ASP later on.
From the 'Start menu', click on 'Administrative Tools' and click on 'Internet Information Services (IIS) Manager'. Right-click on the 'Web Sites' container and choose 'New->Web Site':
(Click on the picture to enlarge)
The 'Web Site Creation Wizard' is shown, guiding you thorugh the process of creating a new web site. Provide all necessary information:
You're now able to write an ASP script to use IP protocols with ActiveSocket.
To create the ActiveSocket object in php use the following code:
$objHttp = new COM (ActiveXperts.Http);
In this sample we have built a page that is able to display the source code of another page. You're also able to get source codes from secured area's if you fill in the username and the password. The results are displayed in the page. To do this, we're using the following code.
<?
$url = $_POST['url'];
if($url != ""){
//first create the object, activeXperts.http is a com object
$objHttp = new COM ("ActiveXperts.Http");
//Fill in the username and password
if($error != 0){
$errormessage = $objHttp->getErrorDescription($objHttp->lasterror);
}
else{
$objHttp->WebAccount = $_POST['username'];
$objHttp->WebPassword = $_POST['password'];
}
$error = $objHttp->Lasterror;
//if the username and password are succesfully set, we can connect the server
if($error != 0){
$errormessage = $objHttp->getErrorDescription($objHttp->lasterror);
}
else{
//connect
$objHttp->Connect($url);
}
$error = $objHttp->Lasterror;
if($error != 0){
$errormessage = $objHttp->getErrorDescription($objHttp->lasterror);
}
else{
//echo the sourcecode of the page
//convert < and > of the code using htmlentities()
echo htmlentities($objHttp->ReadData());
}
}
?>