We do our best to design and code websites so that they look and perform the way they should regardless of device or browser, but the truth is we sometimes we need to code for specific device, browser, or crawler. Whether it's a quick hack or a simply wanting to display different content for a given device, you eventually need that information. apilayer has created an amazing api, , to help you!
我们会尽力设计和编码网站,以便无论使用何种设备或浏览器,它们的外观和执行方式均应如此,但事实是有时我们需要为特定的设备,浏览器或搜寻器编码。 无论是快速入侵还是只是想为给定设备显示不同的内容,您最终都需要该信息。 apilayer创建了一个了不起的api 来帮助您!
快速点击 (Quick Hits)
- All you need to do is provide the user agent to get a detailed summary of the user's device 您需要做的就是提供用户代理以获取用户设备的详细摘要。
The is free to use
是免费使用的
- Supports multiple output formats (json and xml) 支持多种输出格式(json和xml)
- Provides bulk lookup as well as single lookup 提供批量查找以及单次查找
- Trusted by ZenDesk, Amazon, Apple, and Lyft 受到ZenDesk,Amazon,Apple和Lyft的信任
Created by , creators of other amazing APIs like , , , and more
由创建,其他令人惊叹的API的创建者,例如 , , 等
使用用户栈 (Using userstack)
Start by signing up for your . Once you have your API key, you can start using the simple but very useful userstack API.
首先 。 拥有API密钥后,就可以开始使用简单但非常有用的用户堆栈API。
All you need to do is send the API key and user agent to the endpoint and you'll get a logical, informative object that describes the user device, browser, and more:
您所需要做的就是将API密钥和用户代理发送到端点,您将获得一个逻辑丰富的对象,该对象描述用户设备,浏览器等:
curl https://api.userstack.com/api/detect ?access_key=MY_API_KEY &ua=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3672.0 Safari/537.36
{ "ua":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/73.0.3672.0 Safari\/537.36", "type":"browser", "brand":"Apple", "name":"Mac", "url":"https:\/\/www.google.com\/about\/company\/", "os":{ "name":"macOS 10.14 Mojave", "code":"macos_10_14", "url":"https:\/\/en.wikipedia.org\/wiki\/MacOS_Mojave", "family":"macOS", "family_code":"macos", "family_vendor":"Apple Inc.", "icon":"https:\/\/assets.userstack.com\/icon\/os\/macosx.png", "icon_large":"https:\/\/assets.userstack.com\/icon\/os\/macosx_big.png" }, "device":{ "is_mobile_device":false, "type":"desktop", "brand":"Apple", "brand_code":"apple", "brand_url":"http:\/\/www.apple.com\/", "name":"Mac" }, "browser":{ "name":"Chrome", "version":"73.0.3672.0", "version_major":"73", "engine":"WebKit\/Blink" }, "crawler":{ "is_crawler":false, "category":null, "last_seen":null }}
The returned object provides a wealth of information, parsed and placed into logical sections:
返回的对象提供了大量信息,这些信息已解析并放入逻辑部分:
device
:is_mobile_device
is a very useful property to incorporate for your design layoutsdevice
:is_mobile_device
是一个非常有用的属性,可用于您的设计布局browser
: providing version informationbrowser
:提供版本信息crawler
: lets you know if it's a webcrawer or bot, and which bot you arecrawler
:让您知道它是网络爬虫还是机器人,以及您是哪个机器人
You can provide additional parameters to specify just the information you want returned from the API:
您可以提供其他参数以仅指定要从API返回的信息:
curl https://api.userstack.com/api/detect ?access_key=MY_API_KEY &ua=... &fields=device,browser.version
Like other apilayer APIs, userstack allows you to use JSONP:
像其他apilayer API一样,userstack允许您使用JSONP:
curl https://api.userstack.com/api/detect ?access_key=MY_API_KEY &ua=... &callback=MY_FUNCTION_NAME
What I love about apilayer APIs is that they're always simple to use and were constructed for a very specific purpose. What provides is so useful and I can trust it to be accurate and maintained. Give userstack a look -- it's worth your time to get accurate, usable useragent information!
我喜欢apilayer API的原因在于它们总是易于使用,并且是为特定目的而构造的。 用户提供的功能非常有用,我可以相信它是准确的并可以维护。 让用户看一下-值得您花费时间获取准确,可用的用户代理信息!
翻译自: