User agent
What is a user agent? See https://en.wikipedia.org/wiki/User_agent for a detailed description.
The ITscope Loadbalancer that accepts the API requests has some protection mechanisms for DoS, Flooding and search engine queries. To prevent you from falling victim to these protection mechanisms, you should set user agents when retrieving API requests. The examples listed below should help you to implement your scripts correctly.
Meanwhile, certain user agents are filtered against DoS and Flooding, e.g. Snoopy, Smarty but also not set (zero) user agents.
Our servers also filter certain search engine user agents, e.g. bot spider search seek retriever checker agent crawler gonzo yandex snoopy slurp Indy.
ERPs and other applications
For applications that always use a fixed user agent, it is sufficient for the user agent to consist of a combination of the company name (name of the company that developed the application), the name of the application and the version of the application.
e.g. Developing company – Application name – Application version
Shops and search engines
Shops should not send a fixed user agent to the ITscope API. Instead, the user agent is the browser with which the customer navigates in the shop.
For this reason it is very important that the user agent of the requesting customer is forwarded correctly to the ITscope API, in the event that ITscope API calls are used in a shop. This allows our Loadbalancer to recognise that the request comes from a normal user browser and not from a search engine.
Effects
If a user agent is identified as a search engine, then the ITscope API Request will be delivered with a varying delay (10-20 seconds). This way, the Loadbalancer prevents the real customer from having unnecessary loading times when using the ITscope services.
Flooding, DoS or no (zero) user agents can be blocked very quickly, so a user agent should always be set for your own security.
Examples of PHP queries
This section contains instructions regarding PHP scripts for transferring user agents.
Currently, many web services are delivered to customers with incorrect or no user agent. We therefore ask you to reconfigure your queries according to the instructions below.
Snoopy
Changes in the Snoopy.class.php file
// UserAgent Code Start
// var $ agent = "Snoopy v1.2.4";
Var $ agent = $ _ SERVER ['HTTP_USER_AGENT'];
// UserAgent Code End
Smarty Template Engine
Changes in the following file: smarty/libs/plugins/function.fetch.php->smarty_function_fetch
// UserAgent Code Start
// $ agent = "Smarty Template Engine". $ Smarty -> _ version;
$ Agent = $ _SERVER ['HTTP_USER_AGENT'];
// UserAgent Code End
Curl
Expand the curl_setOpt statement
// UserAgent Code Start
Curl_setopt ($ ch, CURLOPT_USERAGENT, $ _SERVER ['HTTP_USER_AGENT']);
// UserAgent Code End
File_get_contents
The function call should look like this
// UserAgent Code Start
$ Opts = array (
'Http' => array (
'Header' => "User Agent:". $ _SERVER ['HTTP_USER_AGENT']. "\ R \ n"
)
);
$ Context = stream_context_create ($ opts);
$ TheirVariable = file_get_contents ($ url, false, $ context);
// UserAgent Code End
Fsockopen
Example with user agent
$ Fp = @fsockopen ($ url, 80, $ errno, $ errstr, $ timeout);
$ Out = "GET / HTTP / 1.0 \ r \ n";
$ Out. = "Host: www.example.com \ r \ n";
// UserAgent Code Start
$ Out. = 'User Agent:'. $ _ SERVER ['HTTP_USER_AGENT']. "\ R \ n";
// UserAgent Code End
Fopen
Example with user agent
// UserAgent Code Start
Ini_set ('user_agent', $ _ SERVER ['HTTP_USER_AGENT']);
// UserAgent Code End
$ Result = @fopen ($ url, "r");
Varien_Http_Client (Magento)
Example for the following file: magento\lib\Varien\Http\client.php
Class Varien_Http_Client extends Zend_Http_Client
{
Public function __construct ($ uri = null, $ config = null)
{
// $ this-> config ['useragent'] = 'Varien_Http_Client';
$ This-> config ['useragent'] = $ _SERVER ['HTTP_USER_AGENT'];
Parent :: __ construct ($ uri, $ config);
}
Examples C #
HttpWebRequest
Set the user agent variable in the HttpWebRequest to the name of your company and application
HttpWebRequest myHttpWebRequest = HttpWebRequest) WebRequest.Create ("https: //api.itscope.com ...");
MyHttpWebRequest.UserAgent = "applicationCompany-applicationName-applicationVersion";
HttpWebResponse myHttpWebResponse = (HttpWebResponse) myHttpWebRequest.GetResponse ();
Examples C ++
HttpWebRequest
Set the user agent variable in the HttpWebRequest to the name of your company and application
HttpWebRequest ^ myHttpWebRequest = (HttpWebRequest ^) (WebRequest :: Create ("https: //api.itscope.com ..."));
MyHttpWebRequest-> UserAgent = "applicationCompany-applicationName-applicationVersion";
HttpWebResponse ^ myHttpWebResponse = (HttpWebResponse ^) (myHttpWebRequest-> GetResponse ());
Examples Visual Basic VB
HttpWebRequest
Set the user agent variable in the HttpWebRequest to the name of your company and application
Dim myHttpWebRequest As HttpWebRequest = CType (WebRequest.Create ("https: //api.itscope.com ...."), HttpWebRequest)
MyHttpWebRequest.UserAgent = "applicationCompany-applicationName-applicationVersion"
Dim myHttpWebResponse As HttpWebResponse = CType (myHttpWebRequest.GetResponse (), HttpWebResponse)
Examples Java
Apache HttpGet
Set the user agent variable in the HttpGet to the name of your company and application
HttpGet myHttpWebRequest = new HttpGet("https://api.itscope.com....");
myHttpWebRequest.setHeader("User-Agent","applicationCompany-applicationName-applicationVersion");