Access the Import.io API through a proxy server

I'm having problems using the import.io API.

Despite the fact that my application was used and deployed in the UK, it will return (for certain stores) incorrect currencies and price data due to the fact that Import.IO servers will be deployed in the USA. I spoke with a support team that helped me to inform that I can host a proxy server for the import API.

I was able to start an AWS instance and install Squid as a proxy. I changed the settings for connecting to Firefox and successfully browsed web pages through this proxy server (also confirmed that my ip was the IP address of my server)

However, I'm not quite sure exactly how I'm going to call the Import library from my application.

The application is built in PHP, and the current example of how I will generate the URL to call will be:

public function generateCall( $import_key, $url )
{
    return sprintf(
        'https://api.import.io/store/data/%s/_query?input/webpage/url=%s&_user=XXXX&_apikey=%s',
        $import_key, urlencode( $url ), self::$apikey
    );
}

I directly call the api.import.io server.

+4
source share
2 answers

You can use CURL and get the API. Then you can find proxies from a specific country to get API data by country.

$user = 'User';
$key = 'key';
$url = 'https://api.import.io/store/data/%s/_query?input/webpage/url=%s&_user=XXXX&_apikey=%s';
$proxy = '127.0.0.1:8888';
//$proxyauth = 'user:password';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);

echo $curl_scraped_page;
+4
source

If I understand your problem correctly, you are trying to access the import.io resource through your squid proxy. There are several options for doing this.

+1
source

All Articles