Ulyssesonline

the tech surfer

  • Home
  • About
  • Archives
You are here: Home / 2009 / Archives for November 2009

Archives for November 2009

November 28, 2009

Retrieve The Latest Twitter Trends

Here’s a simple and short tutorial on how to retrieve Twitter trends. We will be using PHP and Twitter’s API to retrieve the latest trends. You can publish the trends on your website, blog or any application you are working on. So, let’s get started.

Twitter has made trends available to anyone via API calls. The url of the API is: http://search.twitter.com/trends.json. Trends is also available in XML, but we will use JSON in this example.

To retrieve the string of data, we will use a PHP command called file_get_contents. We will suppress errors by placing an @ sign in front of file_get_contents. We will assign the string to a variable called $contents. So this is what we have so far.

$contents = @file_get_contents("http://search.twitter.com/trends.json");

$contents = @file_get_contents("http://search.twitter.com/trends.json");

Next, we will check if we have the correct response from the http_header. We will check for the code “200”, meaning we have a valid response. We will use the PHP command called strpos to find the needle in the haystack. The needle in this case is “200.” We will look for it starting at position “0.” The format is going to be like this.

$contents = @file_get_contents("http://search.twitter.com/trends.json");
if (strpos($http_response_header[0], "200")) {
  echo "ok";
} else {
  echo "fail"
}

$contents = @file_get_contents("http://search.twitter.com/trends.json"); if (strpos($http_response_header[0], "200")) { echo "ok"; } else { echo "fail" }

Ok, so we now have a JSON string assigned to the variable named $contents. We just need to decode it using the PHP command called “json_decode” and assign it to the $json array variable. Next, we will run a foreach contruct to echo each trend name.

$contents = @file_get_contents("http://search.twitter.com/trends.json");
if (strpos($http_response_header[0], "200")) {
  $json = json_decode($contents);
  foreach ($json->trends as $trend) {
        echo $trend->name;
      }
} else {
}

$contents = @file_get_contents("http://search.twitter.com/trends.json"); if (strpos($http_response_header[0], "200")) { $json = json_decode($contents); foreach ($json->trends as $trend) { echo $trend->name; } } else { }

So, there you have it. We now have the latest Twitter trends using PHP and Twitter’s API.

Filed Under: General, HTML, PHP Tagged With: api, file_get_contents, json, json_decode, PHP, strpos, twitter

November 25, 2009

It’s Official No More Gimp in Ubuntu

It’s Official No More Gimp in Ubuntu

The latest decision by the Ubuntu development team to exclude Gimp in future releases of Ubuntu was a bit of a head scratcher. I wondered why Gimp had to be taken out of future releases of Ubuntu.

Gimp is a powerful program for editing graphics that we all love. It offers everyone an alternative tool to Adobe’s Photoshop. It’s rich in features and capabilities. Although it not quite up to par with Photoshop, it certainly can hold its own.

Ubuntu developers explained the reasoning behind the removal. They said Gimp was too complicated, too intimidating to casual users. Too complicated? And Linux is not? Gimp developers seem to agree about leaving it out.

So, with no Gimp in Ubuntu’s future, users are encouraged to use F-Spot, a mono application I might add. And that may not even stick. Developers are already talking about replacing F-Spot with Shotwell or Gthumb.

The good news is it’s easy to install Gimp. It will probably be the first application I will install after installing Ubuntu. That’s if I’m still using Ubuntu.

Filed Under: General, Linux Tagged With: f-spot, gimp, gthumb, photoshop, shotwell, ubuntu

November 23, 2009

Increase PHP File Upload Limit

If you have installed a LAMP server either on your Linux desktop or server, you are bound to run into this problem. The default PHP installation placed a 2MB limit on file uploads. I ran into this problem when I tried to import a XML file that was bigger than 2MB into a WordPress install. So, to increase the upload limit, I edited the PHP configuration file called PHP.INI.

In Ubuntu, the default location for PHP.INI is in the /etc/php5/apache2 directory. So, let’s open up the Terminal and edit the PHP.INI file:

$ sudo vi /etc/php5/apache2/php.ini

$ sudo vi /etc/php5/apache2/php.ini

Look for this entry in the file.

upload_max_filesize = 2M

upload_max_filesize = 2M

Increase the limit to 10MB or to any value you prefer.

upload_max_filesize = 10M

upload_max_filesize = 10M

Save file and exit.

Next, you will need to restart the Apache server for your changes to take effect. From the Terminal type this command to restart your Apache web server:

$ sudo /etc/init.d/apache2 restart

$ sudo /etc/init.d/apache2 restart

That’s it. Have fun uploading large files!

Filed Under: General, Linux, PHP Tagged With: configuration, PHP, upload file size limit, WordPress

  • 1
  • 2
  • 3
  • Next Page »

Copyright © 2003 - 2018