PHP code example of pthreat / ipqs

1. Go to this page and download the library: Download pthreat/ipqs library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pthreat / ipqs example snippets


    public function __construct(
        private \GuzzleHttp\ClientInterface $client,
        private string $key
    ) {

    use GuzzleHttp\Client;
    use IPQS\Service\Email\Options\EmailVerificationOptions;
    
    $ipqs = new IPQS\IPQS(key: 'MY-IPQS-API-KEY');
    
    $result = $ipqs->email()->verify(
        value: '[email protected]',
        options: new EmailVerificationOptions(
            fastResponse: true,
            replyTimeout: 7,
            abuseStrictness: 0
        )
    );

    /**
     * @see src/IPQS/Service/Email/Response/EmailVerificationResponseInterface.php
     * For a comprehensive list of all available methods.
     */           
    var_dump($result->getDeliverability());
    var_dump($result->getFirstName());
    var_dump($result->isDisposable());

    use GuzzleHttp\Client;
    use IPQS\Service\IP\Options\IPVerificationOptions;
    
    $ipqs = new IPQS\IPQS(key: 'MY-IPQS-API-KEY');
    
    $result = $ipqs->ip()->verify(
        value: '127.0.0.1',
        options: new IPVerificationOptions(
            strictness: 0,
            allowPublicAccessPoints: true,
            mobile: false,
            lighterPenalties: false,
            userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36',
            userLanguage: 'en-US'
        )
    );

    /**
     * @see src/IPQS/Service/IP/Response/IPVerificationResponseInterface.php
     * For a comprehensive list of all available methods.
     */        
    var_dump($result->getFraudScore());
    var_dump($result->getIsp());
    var_dump($result->getCity());
    var_dump($result->getCountryCode());

    use GuzzleHttp\Client;
    use IPQS\Service\Phone\Options\PhoneVerificationOptions;
    
    $ipqs = new IPQS\IPQS(key: 'MY-IPQS-API-KEY');

    $result = $ipqs->phone()->verify(
        value: '5491199999999',
        options: new PhoneVerificationOptions(
            countries: [],
            strictness: 0
        )
    );

    /**
     * @see src/IPQS/Service/Phone/Response/PhoneVerificationResponseInterface.php
     * For a comprehensive list of all available methods.
     */           
    var_dump($result->isVoip());
    var_dump($result->isPrepaid());
    var_dump($result->getLineType());
    var_dump($result->getCountry());
    var_dump($result->getCarrier());
text
^ array:35 
  "message" => "Success."
  "success" => true
  "valid" => true
  "disposable" => false
  "smtp_score" => 3
  "overall_score" => 4
  "first_name" => "JOHN DOE"
  "generic" => false
  "common" => true
  "dns_valid" => true
  "honeypot" => false
  "deliverability" => "high"
  "frequent_complainer" => false
  "spam_trap_score" => "none"
  "catch_all" => false
  "timed_out" => false
  "suspect" => false
  "recent_abuse" => false
  "fraud_score" => 0
  "suggested_domain" => "N/A"
  "leaked" => true
  "domain_age" => array:3 [
    "human" => "30 years ago"
    "timestamp" => 808286400
    "iso" => "1995-08-13T00:00:00-04:00"
  ]
  "first_seen" => array:3 [
    "human" => "8 years ago"
    "timestamp" => 1483250461
    "iso" => "2017-01-01T01:01:01-05:00"
  ]
  "domain_trust" => "trusted"
  "sanitized_email" => "[email protected]"
  "domain_velocity" => "high"
  "user_activity" => "Disabled for performance. Contact support for further assistance."
  "associated_names" => array:2 [
    "status" => "Associated names found."
    "names" => array:1 [
      0 => "JOHN DOE"
    ]
  ]
  "associated_phone_numbers" => array:2 [
    "status" => "No associated phone numbers found."
    "phone_numbers" => []
  ]
  "risky_tld" => false
  "spf_record" => true
  "dmarc_record" => true
  "mx_records" => array:5 [
    0 => "alt4.gmail-smtp-in.l.google.com"
    1 => "alt1.gmail-smtp-in.l.google.com"
    2 => "gmail-smtp-in.l.google.com"
    3 => "alt2.gmail-smtp-in.l.google.com"
    4 => "alt3.gmail-smtp-in.l.google.com"
  ]
  "a_records" => array:8 [
    0 => "74.125.21.83"
    1 => "74.125.21.18"
    2 => "74.125.21.17"
    3 => "74.125.21.19"
    4 => "142.251.15.18"
    5 => "142.251.15.83"
    6 => "142.251.15.17"
    7 => "142.251.15.19"
  ]
  "request_id" => "xxxxxxxx"
]