ไคลเอนต์ PHP สำหรับการเชื่อมต่อกับบริการ API ที่ BigDataCloud มอบให้
BigDataCloud นำเสนอ API ที่มีประโยชน์อย่างยิ่งและรวดเร็วมากมาย ซึ่งสามารถใช้ได้ทั้งในสถานการณ์แบ็กเอนด์และฟรอนต์เอนด์ ตั้งแต่การตรวจสอบอินพุตของลูกค้าแบบเรียลไทม์ไปจนถึงเทคโนโลยี IP Geolocation รุ่นต่อไป BigDataCloud มี API ที่เหมาะกับความต้องการของคุณ
คุณสามารถเข้าถึง BigDataCloud API ใดๆ ทั้งหมดได้ด้วยคีย์ API ฟรี หากต้องการรับคีย์ API เพียงเข้าถึงบัญชีของคุณและดึงข้อมูลจากแดชบอร์ดบัญชีของคุณ หากคุณยังไม่ได้เป็นลูกค้า คุณสามารถเข้าร่วมได้ฟรีโดยสมบูรณ์
BigDataCloud API ทั้งหมดรวมอยู่ในแพ็คเกจ API ที่แตกต่างกันห้าแพ็คเกจ แพ็คเกจ API แต่ละแพ็คเกจมีแผนการสมัครและราคาของตัวเอง
คุณสามารถดูรายละเอียดเพิ่มเติมได้ในหน้าแพ็คเกจ API ที่เกี่ยวข้อง
สำหรับเอกสารเฉพาะสำหรับไคลเอนต์ API นี้ โปรดอ่านด้านล่าง สำหรับเอกสารประกอบเฉพาะเพิ่มเติมของ API ที่พร้อมใช้งาน รวมถึงตำแหน่งข้อมูล คำขอ และข้อมูลการตอบสนอง โปรดไปที่หน้าแพ็คเกจ API ที่เกี่ยวข้อง
หากต้องการใช้ไคลเอ็นต์ API นี้ คุณต้องมีคีย์ BigDataCloud API หากต้องการรับรหัสส่วนตัว เพียงเข้าถึงบัญชีของคุณและดึงข้อมูลจากแดชบอร์ดบัญชีของคุณ หากคุณยังไม่ได้เป็นลูกค้า คุณสามารถเข้าร่วมได้ฟรีโดยสมบูรณ์
เพียงระบุคีย์นี้เมื่อเริ่มต้น php api client และคีย์นี้จะรวมอยู่ในคำขอทั้งหมดที่ส่งไปยังเซิร์ฟเวอร์ BigDataCloud API ดูตัวอย่างด้านล่าง
composer require bigdatacloudapi/php-api-client
<?php
//Installed via Composer
require_once __DIR__ . ' /vendor/autoload.php ' ;
//Installed manually
//Using composer installed location for example, simply reference the /src/Client.php where extracted/installed instead.
//require_once __DIR__ . '/vendor/bigdatacloudapi/php-api-client/src/Client.php';
$ apiKey = " XXX " ; // Your api key found at: https://www.bigdatacloud.com/account
$ client = new BigDataCloud Api Client ( $ apiKey );
/*
Can specify the api endpoint using either camelised magic methods, or by calling the communicate command directly.
Example magic method: "GET" from "ip-geolocation-full" endpoint becomes: getIpGeolocationFull();
*/
//$result=$client->communicate('ip-geolocation-full','GET',['ip'=>'8.8.8.8']);
$ result = $ client -> getIpGeolocationFull ([ ' ip ' => ' 8.8.8.8 ' ]);
var_dump ( $ result );
{
"ip" : "8.8.8.8" ,
"country" : {
"isoAlpha2" : "US" ,
"isoAlpha3" : "USA" ,
"m49Code" : 840 ,
"isoName" : "United States of America (the)" ,
"isoAdminLanguages" : [
{
"isoAlpha3" : "eng" ,
"isoAlpha2" : "en" ,
"isoName" : "English"
}
] ,
"unRegion" : "Americas/Northern America" ,
"currency" : {
"numericCode" : 840 ,
"code" : "USD" ,
"name" : "US Dollar" ,
"minorUnits" : 2
} ,
"wbRegion" : {
"id" : "NAC" ,
"iso2Code" : "XU" ,
"value" : "North America"
} ,
"wbIncomeLevel" : {
"id" : "HIC" ,
"iso2Code" : "XD" ,
"value" : "High income"
} ,
"callingCode" : "1" ,
"countryFlagEmoji" : "??"
} ,
"location" : {
"isoPrincipalSubdivision" : "California" ,
"isoPrincipalSubdivisionCode" : "US-CA" ,
"city" : "Mountain View" ,
"postcode" : "94043" ,
"latitude" : 37.42 ,
"longitude" : - 122.09 ,
"timeZone" : {
"ianaTimeId" : "America/Los_Angeles" ,
"displayName" : "(UTC-08:00) Pacific Time (US & Canada)" ,
"effectiveTimeZoneFull" : "Pacific Daylight Time" ,
"effectiveTimeZoneShort" : "PDT" ,
"UtcOffsetSeconds" : - 25200 ,
"UtcOffset" : "-07" ,
"isDaylightSavingTime" : true ,
"localTime" : "2019-04-06T04:06:39.1691744"
}
} ,
"lastUpdated" : "2019-04-06T09:09:36.1877959Z" ,
"network" : {
"registry" : "ARIN" ,
"registryStatus" : "assigned" ,
"registeredCountry" : "US" ,
"registeredCountryName" : "United States of America (the)" ,
"organisation" : "Google LLC" ,
"isReachableGlobally" : true ,
"isBogon" : false ,
"bgpPrefix" : "8.8.8.0/24" ,
"bgpPrefixNetworkAddress" : "8.8.8.0" ,
"bgpPrefixLastAddress" : "8.8.8.255" ,
"totalAddresses" : 256 ,
"carriers" : [
{
"asn" : "AS15169" ,
"asnNumeric" : 15169 ,
"organisation" : "Google LLC" ,
"name" : "GOOGLE" ,
"registry" : "ARIN" ,
"registeredCountry" : "US" ,
"registeredCountryName" : "United States of America (the)" ,
"registrationDate" : "2000-03-30" ,
"registrationLastChange" : "2012-02-25" ,
"totalIpv4Addresses" : 8698103 ,
"totalIpv4Prefixes" : 435 ,
"totalIpv4BogonPrefixes" : 0 ,
"rank" : 53 ,
"rankText" : "#53 out of 62,872"
}
] ,
"viaCarriers" : [
{
"asn" : "AS7018" ,
"asnNumeric" : 7018 ,
"organisation" : "ATT Services Inc." ,
"registeredCountry" : "US" ,
"registeredCountryName" : "United States of America (the)" ,
"rank" : 2
} ,
/*........*/
{
"asn" : "AS31019" ,
"asnNumeric" : 31019 ,
"organisation" : "Paulus M. Hoogsteder trading as Meanie" ,
"registeredCountry" : "NL" ,
"registeredCountryName" : "Netherlands (the)" ,
"rank" : 51153
}
]
} ,
"confidence" : "low" ,
"confidenceArea" : [
{
"latitude" : 18.0256672 ,
"longitude" : - 66.5275345
} ,
/*........*/
{
"latitude" : 18.0256672 ,
"longitude" : - 66.5275345
}
] ,
"securityThreat" : "unknown" ,
"hazardReport" : {
"isKnownAsTorServer" : false ,
"isKnownAsProxy" : false ,
"isKnownAsMailServer" : false ,
"isKnownAsPublicRouter" : false ,
"isBogon" : false ,
"isUnreachable" : false
}
}