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:

A Scala IMAP email client (using SSL, IMAPS, JavaMail)

If you ever need to write an IMAP client in Scala, I hope the following example can be helpful. For my project named SARAH (a Mac OS X Siri-like project), I wanted an IMAP client to periodically check my mail and then say something a little better than, "You've got mail", and the first part of that was getting a Scala IMAP client going.

A Scala REST client using the Apache HttpClient library

After writing a Java REST (RESTful) client using Apache HttpClient, I turned around and modified that code to be a Scala REST client, also using the Apache HttpClient library.

Java Apache HttpClient REST (RESTful) client examples

I've started writing some Java REST (RESTful) clients lately, and in doing so, I've been looking at several different ways to do this, including using the Apache HttpClient project, the Jersey project, Apache CXF, and more.

A Scala Twitter client example

Just a quick note here today that if you want to create a Twitter client in Scala, the Java Twitter4J library looks like a good path to take.

I've shown an example below, where you can see that besides the eight lines of code it takes to create a Scala twitter object, the actual code you need to get information from the Twitter developer API is pretty short.

How to succeed as a consultant

This article is now part of my new eBook, which is only $2.99 on Amazon.com:

You want me to do what? A Survival Guide for New Consultants

I hope you enjoy my book, and more than that, I hope it helps you have a very profitable and rewarding career.

 

The best Mac Git GUI client (2011)

Summary: A short review of Mac Git GUI clients.

A True License example - Part 2, the Java Software License client

(This is my Java TrueLicense example, Part 2. A link to Part 1 of this example is available below.)

Syndicate content