client

Get a web client's IP address with PHP

I just ran into a situation for a Drupal/PHP client where I wanted to log some access information. There was some unusual access activity on the website, and I want to log IP addresses and URLs for a few days.

As part of that, I wanted to get the web client's IP address, and in PHP you get the client IP address like this:

$ip = $_SERVER['REMOTE_ADDR'];

That returns something like this:

192.168.100.10

If you just need to get a web client's IP address from a PHP script, that's all you need.

A Scala JSON (Gson) HTTP POST RESTful client example

While working on a Scala project recently I created the following example Scala code to test a variety of things, including:

  • Scala case classes
  • The Apache HttpClient classes, including HttpPost
  • Creating JSON with Gson
  • Sending the JSON object/string to my POST RESTful server

Given that brief introduction, here's the source code for my Scala HTTP client, which uses POST (Apache HttpPost) to send data to a RESTful web service:

A Scala REST 'get content' client function using Apache HttpClient

As quick post here today, if you need a Scala REST client function, the following source code should be able to work for you, or at least be a good starting point. I'm using it in several applications today, and the only thing I think it needs is the ability to set a connection timeout and socket timeout, and I share the code for that down below.

Here's my Scala REST 'get content' client function, using the Apache HttpClient library:

Syndicate content