semifor / Net-Twitter

A Perl interface to the Twitter APIs
83 stars 37 forks source link

proxy support #74

Closed mhpchaves closed 7 years ago

mhpchaves commented 7 years ago

First of all, thank you very much for maintaining this module and keeping it updated! Any plans to add proxy support to Net::Twitter module? Thank's again!

semifor commented 7 years ago

Net::Twitter, by default, uses LWP::UserAgent internally. So, you should be able to use it's proxy support. If I understand it's documentation, setting the appropriate environment variables and calling $nt->ua->env_proxy should work.

Unrelated to the proxy issue, please give Twitter::API a try. It's a rewrite of Net::Twitter with fewer dependencies and avoids many of the contortions Net::Twitter goes through to provide backwards compatibility with both older versions of itself and the Twitter API.

It, by default, uses HTTP::Tiny internally. If I understand it's documentation, simply setting the appropriate environment variables will get you proxy support.

mhpchaves commented 7 years ago

Thank you very much for the prompt reply. I'll definitely give it a try!

mhpchaves commented 7 years ago

Hi Marc,

I'm replying to this message just to give you some feedback on my last tries.

You've already implemented "ua->env_proxy" statement in subroutine _build_ua. So, all I had to do was to use the environment variables.

When I run my code as showed in the line below,

$ env http_proxy=http://my-proxy.example:3128/ https_proxy= https://my-proxy.example:3128/ my_twitter_code.pl

the following error is returned:

HTTP Response Code: 500 HTTP Message......: Can't connect to my-proxy.example:3128 Twitter error.....: 500 Can't connect to my-proxy.example:3128 at /usr/local/libdata/perl5/site_perl/amd64-openbsd/Class/MOP/Method/Wrapped.pm line 163 HTTP Response Code: 500 HTTP Message......: Can't connect to my-proxy.example:3128 Twitter error.....: 500 Can't connect to my-proxy.example:3128 at /usr/local/libdata/perl5/site_perl/amd64-openbsd/Class/MOP/Method/Wrapped.pm line 163

Of course, if I remove the *_proxy env vars, everything works perfectly.

Thank's, ​ ​Marcelo.

semifor commented 7 years ago

Ah! Hadn't remembered I'd called env_proxy.

Can we close this issue?

mhpchaves commented 7 years ago

Of course Marc. Thank's again.

Em 31 de mar de 2017 14:06, "Marc Mims" notifications@github.com escreveu:

Ah! Hadn't remembered I'd called env_proxy.

Can we close this issue?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/semifor/Net-Twitter/issues/74#issuecomment-290770946, or mute the thread https://github.com/notifications/unsubscribe-auth/AHCJgdqhXIy3-pCnSITyLyttgg65pfdUks5rrTKbgaJpZM4MuZfj .

mhpchaves commented 7 years ago

Marc,

Problem solved! A was using https_proxy=https://my-proxy.example:3128/. I should have used just "http" after the "=" portion, like: https_proxy= http://my-proxy.example:3128/

It worked as you stated in the first reply.

Thank you one more time! Marcelo.

2017-03-31 14:58 GMT-03:00 Marc Mims notifications@github.com:

Closed #74 https://github.com/semifor/Net-Twitter/issues/74.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/semifor/Net-Twitter/issues/74#event-1024514553, or mute the thread https://github.com/notifications/unsubscribe-auth/AHCJgdU7Lwrf9rxVCYLoWi_6D4ToryDOks5rrT7AgaJpZM4MuZfj .