Guzzle Http Client Socks5 Proxy setup (and bonus non-200 response code handling!)

In one of the apps I own at work, we have had some issues with consistent page loads. We are behind an F5 router with a list of iRules that would handily win the "wow, that's way-long dude!" industry award. Every now and then they redirect to weird places or won't load at all. So I wrote a script pulling several hundred URLs from an XLS and passing it to GuzzleHttp (github), which has a lot of handy features so you don't have to code them into curl yourself.

I ran this script over my VPN, and off the VPN and then I wanted to see how it handled other points on the globe, so I scrambled up several Amazon EC2 instances from various places in the world like Singapore to run it through. I set up ssh tunneling

ssh -i ~/.ssh/my.pem -D 2001 -f -C -q -N ec2-user@IP

but it took a few tries to get the proxy stuff to work. I tried naked curl just to verify environmental proxies, passing -x, then --socks5 (which finally worked). Then I read up on Guzzle to set the proxy up there.

Guzzle's client documentation indicates you just have to pass ['proxy' => '<proxy details>'] when instantiating the client, but that didn't seem to work. I put up ip.php to output my IP, expecting to see one from Singapore or Russia but, nyet, it wouldn't work.

use GuzzleHttp\Client;

$client = new Client([
    'base_url' => ['https://api.twitter.com/{version}/', ['version' => 'v1.1']],
    'defaults' => [
        'headers' => ['Foo' => 'Bar'],
        'query'   => ['testing' => '123'],
        'auth'    => ['username', 'password'],
        'proxy'   => 'tcp://localhost:80'
    ]
])

→ → → more ...

December 19th, 2014

No OpenID End Point found

OpenID is wonderful when it works, but it's a little mysterious when it doesn't. A lot of web sites will let you log in using your Facebook or Google accounts, but only a few let you use your own OpenId provider, which stinks because it would be better if they all did. The only site that I use regularly that allows me to log in using my own is Stack Overflow and I love them for it.

→ → → more ...

November 25th, 2014

Now that iOS 8 offers other keyboards, here’s the one I want

I want a new keyboard. Not swype. I want Morse Code.

Dot. Dash. And a space. That, and of course learning morse code. Then I could type out a text without looking. And I could hear a text without looking.  It can be done.  Once I am good at it, it would be awesome. Talk about Nerd Cachet! (no Google, I don't mean "nerdy crochet")

 

 


 

→ → → more ...

September 21st, 2014

How Apple Could Have Done Something Cool w/6

I want a smaller phone. NOT a bigger phone. Give me this, with basic touchscreen functionality (and really awesome voice control):

This is an iPod Nano. Give me a phone this big!

That would be great when I'm going out somewhere, want a phone, to get texts, to read tweets, maybe call someone, meet up with some buddies at the game, take great quality pictures and upload them... and it's TINY. tiny.

→ → → more ...

September 21st, 2014

Vim, Codeigniter and easy unit-test running

I like to edit with vim. I have quite a lot of plugins and it's a pretty complete IDE at this point. I love the modal editing, one key commands, and that it's on pretty much every server and Mac or Linux install (or, at least it's ancestor vi is; I alias vim to vi on my systems anyway, it's 33% shorter and it makes me feel like a bearded hacker from the early 80s).

For one of my jobs, I use CodeIgniter (CI) Framework, which has some built-in unit testing functionality. I like to use this CI Unit testing and not PHPUnit because it is easy to run the tests and keep it all in one format.

→ → → more ...

January 15th, 2013
Older posts