UltraMega Blog
29Dec/096

Snippet: Fetch Twitter Feed (With Retweets) in PHP

Here is a PHP that fetches a Twitter stream for a specified user. It also combines retweets with the regular updates. This puts them all in an array to make it easy to output them however you want.

This snippet uses APC to cache the data, but you can use any caching method such as memcached or database. It should be fairly easy to edit in your own caching.

 
22Dec/090

TempServers Finally Out of Beta

After almost a year since being announced, TempServers is finally out of beta. The system has been stable for months now, and it is ready to go live. The price is set at just 99 cents per hour for all games.

No major changes have been made since the previous announcement, other than some back-end optimizations. However, some major improvements are planned for the future.

Those that provided feedback during the beta have been given 12 hours of credit. More opportunities for free credits will be made available in the near future, so look out for those!

 
15Dec/091

PHP in the Shell

PHP may be most commonly used within a web server to produce web pages, but it is a powerful scripting engine by itself. PHP is an amazingly useful multipurpose tool when used from the command line. This post will show you how to use the PHP Command Line Interface (CLI). Some of the information here is Linux specific, but there are equivalents for Windows.

Accessing the PHP CLI

Obviously the first thing you need to know is how to run PHP from the command line. There are a number of ways to do this, and one way that I prefer.

The method I find easiest is to write your script as a shell script. This basically means taking a regular PHP script and adding a line to the beginning declaring the php binary to interpret the script. Here's an example:

#!/usr/bin/php
< ?php
echo 'Hello World';
?>

Assuming the file name 'test.php' you would make it executable with chmod +x test.php and run it simply with ./test.php. Note that the file does not need to end with .php to function.

Other options for accessing the PHP CLI are to pass scripts or code to php as parameters, pass code to php through standard input, or enter code manually in interactive mode.

File as parameter:

$ php test.php

Code as parameter:

$ php -r "echo 'Hello World';"

Code through standard input (generate_php_code outputs code):

$ generate_php_code | php

Interactive mode:

$ php -a
Interactive shell
 
php > echo 'Hello World';
Hello World
php >
 
11Dec/090

TempServers Is Looking for a Home

TempServers, the hourly game server rental service, is now for sale. I've been working on this project independently for about a year now and it is very close to being out of beta. The decision to sell was made for a number of reasons.

As a freelance Web developer, I simply don't have the time and resources to run a game server provider. The system itself is designed to be automated, but it still requires monitoring and customer support to operate. One person can't fill all of the roles.

I have created the software behind the concept. Now, it just needs someone in the driver seat. I believe this has a lot of potential to be successful, and I don't think there are any other services like it. If you share this opinion, maybe you can be the driver.

I am currently accepting offers, just contact me at this email address and we can discuss the details.

 
1Dec/091

Using cURL Within PHP

PHP includes an easy to use interface for the cURL library. This means you can easily communicate with other servers using a variety of protocols. It is commonly used to access web service APIs such as Twitter. This tutorial will explain the basics and show some usage examples.

There are 4 main functions you need to know to use cURL: curl_init, curl_setopt, curl_exec, and curl_close. The process generally goes like this:

  1. start a cURL session and get a handle (curl_init)
  2. set the options for the session (curl_setopt)
  3. execute the session (curl_exec)
  4. close the session (curl_close).

The handle returned by curl_init is used as the first parameter in the other functions.

All the available options are listed on the curl_setopt manual page with detailed descriptions.

 
Tagged as: , Continue reading
   

Page optimized by WP Minify WordPress Plugin