WURFL Microservice (by ScientiaMobile, Inc.) is a mobile device detection service that can quickly and accurately detect over 500 capabilities of visiting devices. It can differentiate between portable mobile devices, desktop devices, SmartTVs and any other types of devices that have a web browser.
This is the C#/dotNET Client API for accessing the WURFL Microservice. The API is released under Open-Source and can be integrated with other open-source or proprietary code. In order to operate, it requires access to a running instance of the WURFL Microservice product, such as:
-
WURFL Microservice for Docker: https://www.scientiamobile.com/products/wurfl-microservice-docker-detect-device/
-
WURFL Microservice for AWS: https://www.scientiamobile.com/products/wurfl-device-detection-microservice-aws/
-
WURFL Microservice for Azure: https://www.scientiamobile.com/products/wurfl-microservice-for-azure/
-
WURFL Microservice for Google Cloud Platform: https://www.scientiamobile.com/products/wurfl-microservice-for-gcp/
.NET Framework | WM client version(s) |
---|---|
net8.0 | since 2.2.0 |
net7.0 | since 2.2.0 |
net6.0 | since 2.2.0 |
net5.0 | since 2.1.3 |
netcoreapp3.1 | since 2.1.2 |
netcoreapp2.2 | 2.1.1 |
net481 | since 2.2.0 |
net472 | since 2.2.0 |
net462 | since 2.2.0 |
net452 | since 2.1.3 |
To use this project follow the steps below:
-
Ensure the properly SDK are installed on your machine.
-
Clone or download this repository to your local machine.
-
Open the solution in your preferred IDE (tested with Visual Studio 2022).
-
Build the solution to restore NuGet packages and compile the code.
You may find an example solution of how to use the WmClient dll in the Example folder.
It is a cli app that uses the latest WmClient Nuget package.
Please refer to its source code comments for details.
Alternatively, if code is running inside a web application that provides a HttpRequest instance, you can initialize WM client inside - for example, in the global.asax file
protected void Application_Start()
{
WpcClient client = WpcClient.Create("localhost", "8081");
var requestedCapabilities = new string[]{
"brand_name",
"model_name",
"is_mobile",
"is_tablet",
"is_smartphone"
};
client.SetRequestedCapabilities(requestedCapabilities);
}
and then use it wherever it's needed, for example in a ASP MVC controller method
public ActionResult MyControllerMethod()
{
var req = System.Web.HttpContext.Current.Request;
JSONDeviceData device = client.LookupRequest(req);
[...]
}
You can also use all HTTP headers to perform a device detection:
var headers = new Dictionary<String, String>();
headers.Add("Content-Type", "application/json");
headers.Add("Accept-Encoding", "gzip, deflate");
headers.Add("Accept-Language", "en");
headers.Add("Referer", "https://www.cram.com/flashcards/labor-and-delivery-questions-889210");
headers.Add("User-Agent", "Opera/9.80 (Android; Opera Mini/51.0.2254/184.121; U; en) Presto/2.12.423 Version/12.16");
headers.Add("X-Clacks-Overhead", "GNU ph");
headers.Add("X-Forwarded-For", "110.54.224.195, 82.145.210.235");
headers.Add("X-Operamini-Features", "advanced, camera, download, file_system, folding, httpping, pingback, routing, touch, viewport");
headers.Add("X-Operamini-Phone", "Android #");
headers.Add("X-Operamini-Phone-Ua", "Mozilla/5.0 (Linux; Android 8.1.0; SM-J610G Build/M1AJQ; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.100 Mobile Safari/537.36");
headers.Add("Accept", "text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1");
headers.Add("Device-Stock-Ua", "Mozilla/5.0 (Linux; Android 8.1.0; SM-J610G Build/M1AJQ; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.100 Mobile Safari/537.36");
headers.Add("Forwarded", "for=\"110.54.224.195:36350\"");
// Perform a device detection calling WM server API passing the whole request headers
JSONDeviceData device = client.LookupHeaders(headers);
We want you to know that contributions to this project are welcome. Please open an issue or submit a pull request if you have any ideas, bug fixes, or improvements.
This project is released under Apache-2.0 license.