Support » Plugin: Smash Balloon Social Post Feed » Proxy support

  • Resolved Dick Visser

    (@usrlocaldick)


    Hi

    I’ve noticed that this plugin does not support HTTP proxies such as Squid.
    In restricted environments with limited outgoing connectivity this is a problem because the plugin doesn’t work. Moreover if the outgoing traffic to https:/graphs.facebook.com is silently dropped by a firewall it will additionally cause a very slow site because the connections make the page hang.
    Attached is a patch for version 2.4 that adds proxy support by means of picking up the settings that people have in their wp-config.php.

    --- custom-facebook-feed.php	2016-04-08 16:19:14.000000000 +0200
    +++ custom-facebook-feed.proxy-ok.php	2016-04-08 16:19:52.000000000 +0200
    @@ -1548,6 +1548,20 @@
             //Use cURL
             if(is_callable('curl_init')){
                 $ch = curl_init();
    +            // Use global proxy settings
    +            if (defined('WP_PROXY_HOST')) {
    +              curl_setopt($ch, CURLOPT_PROXY, WP_PROXY_HOST);
    +            }
    +            if (defined('WP_PROXY_PORT')) {
    +              curl_setopt($ch, CURLOPT_PROXYPORT, WP_PROXY_PORT);
    +            }
    +            if (defined('WP_PROXY_USERNAME')){
    +              $auth = WP_PROXY_USERNAME;
    +              if (defined('WP_PROXY_PASSWORD')){
    +                $auth .= ':' . WP_PROXY_PASSWORD;
    +              }
    +              curl_setopt($ch, CURLOPT_PROXYUSERPWD, $auth);
    +            }
                 curl_setopt($ch, CURLOPT_URL, $url);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    @@ -1575,6 +1589,20 @@
             //Auto detect
             if(is_callable('curl_init')){
                 $ch = curl_init();
    +            // Use global proxy settings
    +            if (defined('WP_PROXY_HOST')) {
    +              curl_setopt($ch, CURLOPT_PROXY, WP_PROXY_HOST);
    +            }
    +            if (defined('WP_PROXY_PORT')) {
    +              curl_setopt($ch, CURLOPT_PROXYPORT, WP_PROXY_PORT);
    +            }
    +            if (defined('WP_PROXY_USERNAME')){
    +              $auth = WP_PROXY_USERNAME;
    +              if (defined('WP_PROXY_PASSWORD')){
    +                $auth .= ':' . WP_PROXY_PASSWORD;
    +              }
    +              curl_setopt($ch, CURLOPT_PROXYUSERPWD, $auth);
    +            }
                 curl_setopt($ch, CURLOPT_URL, $url);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 curl_setopt($ch, CURLOPT_TIMEOUT, 20);

    https://wordpress.org/plugins/custom-facebook-feed/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author smashballoon

    (@smashballoon)

    Hey @usrlocaldick,

    Thanks for the patch. I’ll test it out and should be able to add it into the next update. Just to let you know, you can switch the method that the plugin uses to make the Facebook API request to be the WordPress WP_HTTP class, which I believe includes support for wp-config proxy settings. You can change the request method by using the following setting:

    Facebook Feed > Customize > Misc > Misc Settings > Request Method

    Thanks again, I appreciate you reporting the issue.

    John

    Aha. I didn’t spot that option.
    If that is the case then the patch shouldn;t be needed – i’ll test it out.
    If it works with WP_Http then I think the WP_Http request method should be the default.

    Thanks

    Plugin Author smashballoon

    (@smashballoon)

    No probs. I actually released an update yesterday and included your patch in it, so if you update it should fix the issue for you 🙂

    Thanks again, and I hope you’re having a good weekend!

    John

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Proxy support’ is closed to new replies.