VB.Net |
C# |
PHP |
Javascript |
This is an example of the "get_customers" action using VB.Net. |
Imports System
Imports System.Net
Imports System.IO
Public Sub GetCustomers()
Dim myUri As New Uri("http://localhost/readydesk/API/default.aspx?key=your key here&action=get_customers&cid=*")
If myUri.Scheme = myUri.UriSchemeHttp Then
Dim myRequest As HttpWebRequest = HttpWebRequest.Create(myUri)
myRequest.Method = WebRequestMethods.Http.Get
Dim myResponse As HttpWebResponse = myRequest.GetResponse()
If myResponse.StatusCode = HttpStatusCode.OK Then
Dim reader As New StreamReader(myResponse.GetResponseStream())
Dim responseData As String = reader.ReadToEnd()
myResponse.Close()
If responseData <> "" And Not IsNothing(responseData) Then
Console.WriteLine(responseData)
End If
End If
End If
End Sub
using System;
using System.Net;
using System.IO;
public void GetCustomers()
Uri myUri = new Uri("http://localhost/readydesk/API/default.aspx?key=your key here&action=get_customers&cid=*");
if (myUri.Scheme == myUri.UriSchemeHttp)
{
HttpWebRequest myRequest = HttpWebRequest.Create(myUri);
myRequest.Method = WebRequestMethods.Http.Get;
HttpWebResponse myResponse = myRequest.GetResponse();
if (myResponse.StatusCode == HttpStatusCode.OK)
{
StreamReader reader = new StreamReader(myResponse.GetResponseStream());
string responseData = reader.ReadToEnd();
myResponse.Close();
if (!string.IsNullOrEmpty(responseData) & (responseData != null))
{
Console.WriteLine(responseData);
}
}
}
}
function GetCustomers(){
$fp = fsockopen("localhost", 80, $errno, $errstr);
if (!$fp)
{
echo "$errstr ($errno)<br />\n";
}
else
{
$out = "GET /readydesk/API/default.aspx?key=your key here&action=get_customers&cid=* HTTP/1.0\r\n";
$out = $out . "Host: localhost\r\n";
$out = $out . "Connection: Close\r\n\r\n";
fputs($fp, $out);
while (!feof($fp))
{
$responseData .= fgets($fp, 1024);
}
fclose($fp);
if($responseData != "" && $responseData != null)
{
echo $responseData;
}
}
}
function GetCustomers(){
varvar xmlh = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP")
var myRequest = "http://localhost/readydesk/API/default.aspx?key=your key here&action=get_customers&cid=*"
xmlh.onreadystatechange = CallBack
xmlh.open("GET",myRequest,true);
xmlh.send(null);
}
function CallBack(){
if(xmlh.readyState == 4)
{
var responseData = xmlh.responseText;
if(responseData != "")
{
alert(responseData)
}
}
}
|