### Install JSON WHOIS API PHP via Composer Source: https://context7.com/jsonwhois/whois-api-php/llms.txt Use Composer to add the jsonwhoisio/adapter package to your project dependencies. ```bash composer require jsonwhoisio/adapter ``` -------------------------------- ### Check Domain Availability Source: https://context7.com/jsonwhois/whois-api-php/llms.txt Initialize the DomainAvailability adapter, set the domain name, and execute the query. Check the 'is_available' property in the result to determine if the domain can be registered. ```php setPayload('example-domain.com'); // Execute the query $Result = $DomainAvailability->run(); // Check for successful execution if (!$Result->isSuccessful()) { echo 'Lookup failed (' . $Result->getStatusCode() . '): ' . $Result->getStatusMessage(); } else { // Access availability status $dataArray = $Result->getDataArray(); echo 'Is Available (array): ' . ($dataArray['is_available'] ? 'Yes' : 'No') . "\n"; echo 'Is Available (direct): ' . ($Result->is_available ? 'Yes' : 'No') . "\n"; } // Expected output: // is_available: true/false indicating domain registration availability ``` -------------------------------- ### Perform an IP WHOIS Lookup Source: https://context7.com/jsonwhois/whois-api-php/llms.txt Initialize the IpWhois adapter with your API key, set the IP address, and run the query. Access IP WHOIS data such as registration date, owner organization, and network details. ```php setPayload('8.8.8.8'); // Execute the query $Result = $IpWhois->run(); // Check for successful execution if (!$Result->isSuccessful()) { echo 'Lookup failed (' . $Result->getStatusCode() . '): ' . $Result->getStatusMessage(); } else { // Access data as array $dataArray = $Result->getDataArray(); echo 'Created date: ' . $dataArray['created'] . "\n"; // Access directly from Result echo 'Created date: ' . $Result->created . "\n"; echo 'Owner: ' . $Result->contacts->owner[0]->organization . "\n"; // Full response structure print_r($dataArray); } // Expected output includes: // - created: IP block registration date // - updated: Last update date // - contacts: Owner and abuse contact information // - network: IP range and CIDR information ``` -------------------------------- ### Perform a Domain WHOIS Lookup Source: https://context7.com/jsonwhois/whois-api-php/llms.txt Initialize the DomainWhois adapter with your API key, set the domain, and run the query. Access results as an array, object, or directly from the Result object. Handles domain registration dates, expiry, registrar, and contact information. ```php setPayload('google.com'); // Execute the query $Result = $DomainWhois->run(); // Check for successful execution if (!$Result->isSuccessful()) { echo 'Lookup failed (' . $Result->getStatusCode() . '): ' . $Result->getStatusMessage(); } else { // Access data as array $dataArray = $Result->getDataArray(); echo 'Expiry date: ' . $dataArray['expires'] . "\n"; // Access data as object $dataObject = $Result->getDataObject(); echo 'Expiry date: ' . $dataObject->expires . "\n"; // Access directly from Result echo 'Expiry date: ' . $Result->expires . "\n"; echo 'Owner Email: ' . $Result->contacts->owner[0]->email . "\n"; // Full response structure print_r($dataArray); } // Expected output includes: // - expires: Domain expiration date // - created: Domain creation date // - updated: Last update date // - contacts: Owner, admin, tech contact information // - registrar: Registrar details // - nameservers: DNS nameservers ``` -------------------------------- ### Configuration Options Source: https://context7.com/jsonwhois/whois-api-php/llms.txt Configure essential settings for the JSON WHOIS API PHP library, including your private API key and SSL verification preferences. ```APIDOC ## Configuration Options ### API Key Set your private API key, which is required for all API requests. ```php ``` ### SSL Verification Optionally disable SSL certificate verification. This is **not recommended** for production environments. ```php ``` ### API Base URL The API base URL is: `https://api.jsonwhois.io` ``` -------------------------------- ### Configure JSON WHOIS API PHP Settings Source: https://context7.com/jsonwhois/whois-api-php/llms.txt Set your API key and optionally disable SSL certificate verification. The API base URL is provided for reference. ```php setPayload('https://google.com', $width, $height); // Optional: Enable transparent background (PNG only) $BrowserScreenshot->setTransparent(BrowserScreenshot::SETTING_TRANSPARENT_TRUE); // Optional: Capture full page instead of viewport only $BrowserScreenshot->setFullPage(BrowserScreenshot::SETTING_FULLPAGE_TRUE); // Optional: Set JPEG quality (1-100, default 85) $BrowserScreenshot->setQuality(90); // Optional: Set request timeout in seconds (wait before screenshot) $BrowserScreenshot->setRequestTimeout(2); // Execute the query $Result = $BrowserScreenshot->run(); // Check for successful execution if (!$Result->isSuccessful()) { echo 'Lookup failed (' . $Result->getStatusCode() . '): ' . $Result->getStatusMessage(); } else { // Get the screenshot data $dataArray = $Result->getDataArray(); // Display as inline image (base64 encoded) echo ''; // Or save to file $imageData = base64_decode($dataArray['base64']); file_put_contents('screenshot.png', $imageData); } // Expected output includes: // - prefix: Data URI prefix (e.g., "data:image/png;base64,") // - base64: Base64-encoded image data ``` -------------------------------- ### Access API Result Data in PHP Source: https://context7.com/jsonwhois/whois-api-php/llms.txt Demonstrates methods available on the Result object to verify request status and retrieve response data in various formats. ```php run(); // Check if the request was successful $success = $Result->isSuccessful(); // Returns: true or false // Get HTTP status code $statusCode = $Result->getStatusCode(); // Returns: 200, 401, 422, etc. // Get human-readable status message $message = $Result->getStatusMessage(); // Returns messages like: // - "The command was processed successfully." // - "The request was not authorised." // - "Well formatted request however some technical issue is preventing the serving of the request." // Get raw JSON response $rawJson = $Result->getRawData(); // Returns: JSON string // Get data as associative array $dataArray = $Result->getDataArray(); // Returns: PHP array // Get data as object $dataObject = $Result->getDataObject(); // Returns: stdClass object // Access properties directly on Result object $value = $Result->propertyName; // Dynamic properties from response ``` -------------------------------- ### HTTP Response Codes and Error Handling Source: https://context7.com/jsonwhois/whois-api-php/llms.txt Understand the standard HTTP status codes returned by the API and how to handle them in your PHP application. ```APIDOC ## HTTP Response Codes The API uses standard HTTP status codes to indicate the outcome of a request. Below are common codes and their meanings: - **200 (RESPONSE_PROCESSED)**: Request processed successfully. - **400 (RESPONSE_COMMAND_UNKNOWN)**: Invalid endpoint specified. - **401 (RESPONSE_UNAUTHORIZED)**: Invalid API key or the account is banned. - **402 (RESPONSE_BILLING)**: Billing issue with the account. - **405 (RESPONSE_COMMAND_INVALID)**: Incorrect HTTP method used (e.g., POST instead of GET). - **409 (RESPONSE_COMMAND_MALFORMED)**: Missing required parameters. - **422 (RESPONSE_UNPROCESSABLE)**: Technical issue, possibly an unresponsive WHOIS server. - **500 (RESPONSE_INTERNAL_SERVER_ERROR)**: A server-side error occurred. ### Example Error Handling ```php run(); switch ($Result->getStatusCode()) { case 200: // Process successful response $data = $Result->getDataArray(); print_r($data); break; case 401: echo "Authentication failed. Please check your API key."; break; case 402: echo "Billing issue detected. Please check your account status."; break; case 422: echo "The request could not be processed due to a technical issue. Please try again later."; break; default: echo "An error occurred: " . $Result->getStatusMessage(); } ?> ``` ``` -------------------------------- ### API Endpoints Overview Source: https://context7.com/jsonwhois/whois-api-php/llms.txt The JSON WHOIS API offers several endpoints for domain and IP analysis, including WHOIS lookups, domain availability checks, IP geolocation, and website screenshots. ```APIDOC ## API Endpoints - **/whois/domain**: Domain WHOIS lookup - **/whois/ip**: IP WHOIS lookup - **/availability**: Domain availability check - **/geo**: IP geolocation lookup - **/screenshot**: Website screenshot capture ``` -------------------------------- ### Perform IP Geolocation Lookup in PHP Source: https://context7.com/jsonwhois/whois-api-php/llms.txt Uses the Geo adapter to retrieve location metadata for a specific IP address. Requires an API key and the JsonWhois library. ```php setPayload('82.4.135.118'); // Execute the query $Result = $IpGeo->run(); // Check for successful execution if (!$Result->isSuccessful()) { echo 'Lookup failed (' . $Result->getStatusCode() . '): ' . $Result->getStatusMessage(); } else { // Access data as array $dataArray = $Result->getDataArray(); echo 'ISO Country code: ' . $dataArray['country_code'] . "\n"; echo 'Demonym: ' . $dataArray['demonym'] . "\n"; // Access directly from Result echo 'ISO Country code: ' . $Result->country_code . "\n"; echo 'Demonym: ' . $Result->demonym . "\n"; // Full response structure print_r($dataArray); } // Expected output includes: // - country_code: ISO country code (e.g., "GB", "US") // - country_name: Full country name // - city: City name // - region: Region/state name // - latitude/longitude: Geographic coordinates // - demonym: Country demonym (e.g., "British", "American") // - timezone: Timezone information ``` -------------------------------- ### Handle HTTP Response Codes in PHP Source: https://context7.com/jsonwhois/whois-api-php/llms.txt Use this switch statement to handle different HTTP status codes returned by the API. It covers successful responses and various error conditions. ```php run(); switch ($Result->getStatusCode()) { case 200: // Process successful response $data = $Result->getDataArray(); break; case 401: // Handle authentication error echo "Authentication failed. Check your API key."; break; case 402: // Handle billing issue echo "Billing issue. Check your account status."; break; case 422: // Handle unprocessable request echo "Request could not be processed. Try again later."; break; default: // Handle other errors echo "Error: " . $Result->getStatusMessage(); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.