Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all articles
Browse latest Browse all 4126

New Post: Can you use a proxy?

$
0
0
TweetInvi doesn't support proxy authentication by default. But I needed that feature and ended up editing the source (didn't want to bother linvi with too many feature requests :D ).

Here's what you can do. In TweetInvi.WebLogic project, file HttpClientWebHelper.cs - change the following code:
if (!string.IsNullOrEmpty(_tweetinviSettingsAccessor.ProxyURL))
{
        handler.Proxy = new WebProxy(_tweetinviSettingsAccessor.ProxyURL);
        handler.UseProxy = true;
}
to
if (!string.IsNullOrEmpty(_tweetinviSettingsAccessor.ProxyURL))
{
    // Parse proxy Url into Urivar proxyUri = new Uri(_tweetinviSettingsAccessor.ProxyURL);

    // Create WebProxy object using data from parsed Urivar proxy = new WebProxy(string.Format("{0}://{1}:{2}", proxyUri.Scheme, proxyUri.Host, proxyUri.Port));

    // Check if Uri has user authentication specifiedif (!string.IsNullOrEmpty(proxyUri.UserInfo))
    {
        // Set credentials to the proxy objectvar creds = proxyUri.UserInfo.Split(':');
        proxy.Credentials = new NetworkCredential(creds[0], creds[1]);
    }

    // Asign proxy to handler
    handler.Proxy = proxy;
    handler.UseProxy = true;
}
Now you should be able to do either of the following:
TweetinviConfig.CURRENT_PROXY_URL = "http://198.232.247.23:4829";
TweetinviConfig.CURRENT_PROXY_URL = "http://user:pass@198.232.247.23:4829";
imlokesh

Viewing all articles
Browse latest Browse all 4126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>