Sunday, August 10, 2014

<![if !supportMisalignedColumns]>
<![endif]> 
The goal


The goal of Proxy Rental API functions is to provide user an ability to switch IPS. For that purpose several API calls have to be made in certain sequence. Below we will describe each necessary operation, functions used for this operations with their appropriate parameters, while further down we will provide an example application demonstrating their usage.

Downloading The PRSetup.exe


You can download the PRSetup.exe from http://www.proxyrental.net/thankyou/. Navigating to this page will download the installation package. You will need proxy Rental program installed in order to use Proxy Rental APIs.

Recommended Software

<![if !supportLists]>·       <![endif]>.NET compiler that supports .NET 4.0: Microsoft Visual Studio 2010
<![if !supportLists]>·       <![endif]>Microsoft Visual C# 2010 Express
<![if !supportLists]>·       <![endif]>Microsoft Visual Basic 2010 Express
<![if !supportLists]>·       <![endif]>Microsoft Visual Studio 2012
<![if !supportLists]>·       <![endif]>Microsoft Visual Studio Express 2012 for Windows Desktop

Add Service Reference

Prior to using ProxyRental APIs, add the following Service Reference to your c# project
http://mprs.proxyrental.net:45679/ProxyRental/SoapClientService (Screenshot)

Opening new session

A Proxy Rental user can switch IPs multiple times.  The actual number depends on the program purchased from Proxy Rental.  However, in order to accomplish any operation with Proxy Rental APIs a user have to have an open SOAP session.
private Session session;
...
session = new Session();
session = client.TryRestoreOrLogin(user, session);

This call authenticates user on the server side and allows subsequent calls to change IPS.
Session type is defined in ProxyRental service reference that should be included in the program.  
Client parameter is of SoapClientServiceClient type and is also defined in ProxyRental service reference as is the user parameter.

User user = new User();
user.Name = userName;
user.Hash = GetEncryptedString(userPwd);

User type has two properties Name and Hash.   Name is self explanatory, while Hash is Encrypted user password.  Each user selects his or her own user name and password during ProxyRental Install procedure, prior to login in.

Encryption is provider via MD5CryptoService defined in System.Security.Cryptography  A sample of encryption function is provided below in the subsequent example. 

In case of success the function  session = client.TryRestoreOrLogin(user, session);
returns session id that needs to be supplied to subsequent functions.  If this function fails then the function might return the following error values.

Error Value
Meaning
00000000-0000-0000-0000-000000000000
unknown behavior (example user is not logged in)
10000000-0000-0000-0000-000000000000
user subscription has expired
20000000-0000-0000-0000-000000000000
Number of allowed sessions has expired
30000000-0000-0000-0000-000000000000
incorrect user name or user password
40000000-0000-0000-0000-000000000000
server is under diagnostics

Change Proxy

Now, once session is established, a user can start changing IPs.  For that purpose one should use Proxy Rental method ChangeProxy.

ChangeProxyResult changeProxyResult = client.ChangeProxy(session);

ChangeProxy method is also defined in ProxyRental service reference.  It accepts session parameter, changes IP, does a number of other internal operations and collects important information that is made available  by calling the following method:
GlobalInfo ginfo = client.GetProxyInfo(session, sort);

Global Information


GetProxyInfo method accepts two parameters: sessionID and sort, where sort could have two possible values specified in enumerator GlobalInfoSort 

GlobalInfoSort.ByDistance
or
GlobalInfoSort.ByState

Sort order starts matter when user deals with geo-location associated with the new IP and will be discussed below.  When changing ip is the only purpose of the call, the sort parameter can be passed as null.  GlobalInfo ginfo = client.GetProxyInfo(session, null);

GlobalInfo structure returns the following information:

public class GlobalInfo
{
  private GlobalInfo[] nearestInfos;
  public string   CurrentIP { get; set; }
  public string   City { get; set; }
  public string   CityCode { get; set; }
  public string   CountryName { get; set; }
  public string   AreaCode { get; set; }
  public string   State { get; set; }
  public string   Latitude { get; set; }
  public string   Longitude { get; set; }
  public TimeSpan ProxyTimeout { get; set; }
  public int      NonDstTimeZone { get; set; }
  public long     CLTime { get; set; }
  public long     CLTimeActuality { get; set; }
  public string   TimeZoneID { get; set; }
  public double   Persistence;
  public double   Health;
}

Below is the description of those data members that are usually are most useful.
Field
Description
nearestInfos
Array containing a list of locations nearest to the Current IP
AreaCode
Area Code of the Current IP
City
City of the Current IP
CityCode
Craigs's List City Code
CountryName
Country of the current IP
CurrentIP
New IP that user gains after switch
Lattitude
Lattitude of the Current IP
Longitude
Longitide of the Current IP
State
State of the Current IP
Persistence
Proxy stability - a value between 0 and 10

Global Information[] nearestInfos
This array, containing the information about nearest locations to the current IP, deserves special consideration.   This information becomes pertinent when an IP happens to be located not in the vicinity of a CL city, but, for example, in some rural area.   In this case, nearestInfos  array provides information regarding surrounding CL cities.  Latitude and  longitude information can be used to determine the distance from the IP location to the CL city.  Please click here for example.






public struct ProxyFilterParams
{
       public float? Persistance;
       public int? ProxyTimeout;
       public ProxyFilterClassification ProxyKind;
       public float SpeedQuality;
}


Test Project




No comments:

Post a Comment