APIからあまりにも多くの情報を取得していますが、これを使用することはできません。この結果から「device_model」と「device_type」のみが必要です。 ?モバイル検出APIの使用方法
{ "DEVICE_MODEL": "エミュレータ"、 "OS_VERSION": "7"、 "ブラウザ": "クローム"、 "browser_versionは": "60"、 "OS" 私はこの結果を取得しています何 「Windows」、「device_type」:「デスクトップ」、「useragent」:「Mozilla/5.0 (Windows NT 6.1)AppleWebKit/537.36(GeckoのようなKHTML) Chrome/61.0.3163.100 Safari/537.36 "、" device_brand ":" 不明」、 "is_bot":偽}
MobileはAPI
<?php
$useragent = $_SERVER['HTTP_USER_AGENT'];
// get api token at https://useragentinfo.co/
$token = "#API_TOKEN";
$url = "https://useragentinfo.co/api/v1/device/";
$data = array('useragent' => $useragent);
$headers = array();
$headers[] = "Content-type: application/json";
$headers[] = "Authorization: Token " . $token;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status != 200) {
die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
}
curl_close($curl);
echo $json_response;
?>
おそらくStackOverflow - soのような公開ディスカッション掲示板にあなたのapiアクセストークンを掲示すべきではありません私はそれを見逃すかもしれない。私はそれを変更することをお勧めします。 – Latheesan
ありがとうございます<3 apiキーが正しくありません前に変更します –