• Resolved flaviorajta3

    (@flaviorajta3)


    Hello!

    It would be nice if we could have the ability to use a proxy when downloading images.
    One way to do it would be to go inside the plugin code and modifying the curl function, but is there an easier way?
    Would the custom function feature help here?

    Regards
    Flavio

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @flaviorajta3

    You can do this by utilizing the http_api_curl hook. Here’s some example code that you can edit for your needs:

    add_action( 'http_api_curl', 'custom_curl_proxy', 10, 3 );
    function custom_curl_proxy( $handle, $r, $url ) {
    	$proxy = '127.0.0.1:8888';
    	$proxyauth = 'user:password';	
    	curl_setopt($handle, CURLOPT_PROXY, $proxy);     // PROXY details with port
    	curl_setopt($handle, CURLOPT_PROXYUSERPWD, $proxyauth);   // Use if proxy have username and password
    	curl_setopt($handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); // If expected to call with specific PROXY type
    }
    Thread Starter flaviorajta3

    (@flaviorajta3)

    Sorry for late reply!

    I think I got it working.
    I added this custom function at the theme’s functions.php. Looking at access logs I can see the proxy being used.
    Thanks for the answer.

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using proxy when curling images!’ is closed to new replies.