Can you use a proxy?

Nov 23, 2014 at 6:24 PM
I was wondering can you use a proxy with Tweetinvi? And How? Thank you
Nov 24, 2014 at 1:57 PM
Anybody help please
Editor
Nov 24, 2014 at 1:58 PM
It's pretty straightforward really. It's even mentioned on the downloads page.

https://tweetinvi.codeplex.com/releases/view/119316#Proxy

Also, you can download the source code and look in the ExampleInvi project.

imlokesh
Marked as answer by imlokesh on 11/24/2014 at 9:46 AM
Nov 24, 2014 at 4:10 PM
You got to be kidding me, I didn't even see that. Thank you so much.
Nov 24, 2014 at 5:00 PM
I sorry to bother again, but will this work with proxy with password? How will it look like? Thanks!
Editor
Nov 24, 2014 at 5:15 PM
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 Uri
    var proxyUri = new Uri(_tweetinviSettingsAccessor.ProxyURL);

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

    // Check if Uri has user authentication specified
    if (!string.IsNullOrEmpty(proxyUri.UserInfo))
    {
        // Set credentials to the proxy object
        var 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
Marked as answer by linvi on 11/25/2014 at 10:27 AM
Nov 24, 2014 at 5:49 PM
Thanks, Okay I go check that out?
Nov 24, 2014 at 6:16 PM
I can't find the "HttpClientWebHelper.cs" file. Just to let you know I install Tweetinvi with packet manager nuget. I don't know if that have any affect of whether I can't find the file or not. I search the whole project file and even did a search through the computer. Thank you.
Editor
Nov 24, 2014 at 6:45 PM
Edited Nov 24, 2014 at 6:45 PM
Hey you gotta download the source code. Edit the file in visual studio. And compile your own dlls.
Coordinator
Nov 25, 2014 at 5:15 PM
Hi,

I think I will add this feature ;)

WORK ITEM

Linvi
Dec 27, 2014 at 4:54 PM
is there any progress on getting this into the main branch?

Am having difficult getting the code to load into any version of visual studio express (discussion : https://tweetinvi.codeplex.com/discussions/575877 ) so cannot make the change myself
Coordinator
Feb 11, 2015 at 12:39 PM
Hi,

This is now part of the Source Code of Tweetinvi 0.9.5.0.
Special thanks to you imlokesh. The code was exactly what was needed, the syntax is good so I kept it.

Cheers,
Linvi
Sep 1, 2015 at 12:12 PM
Hi,

is TweetinviConfig.CURRENT_PROXY_URL per Thread or per credentials?

I have several background worker tasks where I do operations for one twitter user each. So I like to assign a different proxy to each background worker task.

Is setting the CURRENT_PROXY_URL in the constructor of the task the right way to assure that all action within the tasks are done with this proxy setup?

Thanks
Kay
Coordinator
Sep 1, 2015 at 12:53 PM
Hi,
// Application Wide Proxy setup
TweetinviConfig.APPLICATION_PROXY_URL 

// Thread specific proxy setup
TweetinviConfig.CURRENT_PROXY_URL
If you set the APPLICATION_PROXY_URL. All threads created will have a default CURRENT_PROXY_URL set to the value of APPLICATION_PROXY_URL.
You are then free to change it if required.

If the APPLICATION_PROXY_URL is not set, the CURRENT_PROXY_URL will default to null and won't be use.
You are then free to change it if required.

Cheers,
Linvi
Sep 2, 2015 at 8:08 AM
Thanks, works perfectly!