PHP Logo

Using Authentication And file_get_contents()

15th February 2010 - 3 minutes read time

Using file_get_contents() to fetch the contents of a file is quite a common practice. This might be just to get the contents of a text file or to get the ImageCache module in Drupal to pre-cache images. The file_get_contents() function can get a local or remote file and is usually run like this.

$data = file_get_contents($url);

However, when trying to use this function to communicate with an authenticated server you will see the following error appearing.

Read the full article

PHP Logo

PHP Function To Get TinyURL

5th June 2009 - 2 minutes read time

TinyURL is a service where you can convert a long URL string to a really small one. For instance, the following URL, which points to the Googleplex on Google Maps.,-95.712891&sspn=34.512672,45.615234&ie=UTF8&cd=1&z=16

Can be converted to the following.

This is perfect for posting to Twitter or similar microblogging platforms as it saves lots of character space.

Read the full article