UserAgent

What is a UserAgent? See https://de.wikipedia.org/wiki/User_Agent

The ITscope Loadbalancer, which accepts the API requests, has some protection mechanisms for DoS, Flooding and search engine queries. So that you do not become victims of these protection mechanisms is a rule when retrieving API requests, setting UserAgents. The examples below will help you to correct your scripts.

Meanwhile certain user agents against Dos and Flooding be filtered, eg Snoopy, Smarty also unset (null) user agents.

Filter Our server also for specific search engine user agents such as spider bot search seek retriever checker agent crawler gonzo yandex snoopy slurp Indy.

 

Commodities and other applications

For applications that always use a fixed UserAgent, the userAgent comes from a combination of the company name (name of the company that developed the application) and the name of the application and the version of the application

Eg developing company - application name - application version

 

Shops and search engines

Shops should not send a fixed UserAgent to the ITscope API, but the UserAgent is always that of the browser with which the customer navigates in the shop.

Therefore, it is very important, if ITscope API calls are used in a shop, the userAgent of the requesting customer is forwarded correctly to the ITscope API. So our Loadbalancer can recognize that the request comes from a normal user browser and not from a search engine.

 

Effects

If a UserAgent is recognized as a search engine, it will be delivered with a different delay (10-20 seconds) to the ITscope API Request. This means that the Loadbalancer does not prevent the real customer from having unnecessary loading times when using the ITscope services.

Flooding, DoS or no (zero) UserAgents can be blocked very quickly, so always set a UserAgent for their own security.

 

Examples of PHP queries

Instructions for 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 convert your queries according to the instructions below.

Snoopy

Changes in 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 file smarty / libs / plugins / function.fetch.php-> s marty_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

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 UserAgent

  $ 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 UserAgent

  // UserAgent Code Start 
Ini_set ('user_agent', $ _ SERVER ['HTTP_USER_AGENT']);
// UserAgent Code End
$ Result = @fopen ($ url, "r");

 

Varien_Http_Client (Magento)
Example for 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

In the HttpWebRequest, set the variable UserAgent 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

In the HttpWebRequest, set the variable UserAgent 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

In the HttpWebRequest, set the variable UserAgent 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)

Note: This page has been translated with the Google Translation Service.

Have more questions? Submit a request