skip to Main Content

After upload, this code gets the error on ip2proxy not found on the server. I have already installed ip2proxy extension.

use IlluminateHttpRequest;
use IlluminateRoutingController as BaseController;
use IP2ProxyLaravel;

class Controller extends BaseController
{
    public function lookup(Request $request)
    {
        $get_ip = "89.39.104.204";
        $records = IP2ProxyLaravel::get($get_ip, 'bin');  
        if ($records['isProxy']) {
            return view('proxy');
        } else {
            return view('non-proxy');
        }
    }
}

2

Answers


  1. Chosen as BEST ANSWER

    I'm using

    https://iphub.info/

    alternate of ip2proxy

        $ip = $_SERVER["REMOTE_ADDR"];
        $apikey = "MTg4ODk6MlNXYfd1p6M3JhhjhdjfhoaUI3dW1xNXZdfdfdkNlRMM21dfyQUVhZUpYS0c="; // My API Key
    
        $curl = curl_init();
        curl_setopt_array($curl, array(
        CURLOPT_URL => "http://v2.api.iphub.info/ip/".$ip,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_CUSTOMREQUEST => "GET",
        CURLOPT_HTTPHEADER => array(
            "x-key: ".$apikey
        ),
        ));
    
        $response = json_decode(curl_exec($curl));
        $err = curl_error($curl);
        curl_close($curl);
    
        $block = 0;
        if ($err) {
        echo "cURL Error :" . $err;
        } else {
        $block = $response->block;
        }
    
        if($block == 1){
        echo "Using VPN or Proxy.";
        }else{
        echo "Not using VPN or Proxy.";
        }
    
        echo "<pre>";
        print_r($response);
        echo "</pre>";
    

  2. First of all, did you run the command composer require ip2location/ip2proxy-laravel in your laravel main folder?

    You should be able to see this line "ip2location/ip2proxy-laravel": "^1.1", in your laravel/composer.json after you run the command above.

    Then, you may follow the steps in https://github.com/ip2location/ip2proxy-laravel#usage for the IP2Proxy laravel extension usage.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search