Discover & Rate New Music Check out ChartVote. Promote the music you like.

Archive for October, 2007

Blogging Tip: Don’t post too much content in one day

There is such a thing as posting too much on your blog, just as there is such a thing as not posting enough. I usually have a problem with not posting enough because my attention is usually occupied with some crazy idea project of mine.

I’ve put together a not-so-comprehensive list of reasons not too post too much content in a day.

Reasons not to post too much:
- Readers can’t digest all the content
- Readers tend to overlook your posts more often
- Content usually starts to lose quality
- And the worse case: Readers will remove you from their RSS reader

I was an avid reader the gadget blogs Gizmodo and Engadget for a good few months, but I just got tired of keeping up with all the content. Each day they were posting at least 30-40 articles and I didn’t have the time to sift through them all to find the content I was actually interested in. So I removed them both from my RSS reader.

I hate to say this, but one of my favorite blogs, Mashable has been pumping out the posts lately too and I’ve noticed a decline in the quality of their content.

Screenshot of my Google Reader Stats
rss1.gif

Moral of the story? Stay in the middle. Don’t post too little or too much. Where do you ask is that middle point? For me personally, 1-5 high quality posts in a day is the range I like the most.

Download MP3s from MySpace with PHP

Disclaimer: This code is not meant to be used in any malicious way. Its only a proof of concept and should not be used to illegal download music. I am not responsible for any damages caused by this code. Use at your own risk.

Now that I got that out of the way...have at it.

How it works
With this PHP code you can specify the friendID of any artist on MySpace and it will download all the songs from the artist's profile. URLs to MP3s on MySpace have a one-time use token in them that only allows the URL to be used once, thus allowing the MP3 to be accessed only once per request. This script grabs all the parts needed to construct this URL with the token in it and grabs the MP3 like a normal browser would or like the song player on artist profiles.

This code is only a snippet of a MySpace crawler that I wrote that can spider and categorize MP3s on MySpace. My version is much more advanced in functionality so I am only posting the "meat" of the code here. Why? Because I am in a generous mood and plus its not exactly rocket science to do this.

The Code

PHP:
  1. <?php
  2.  
  3.     $artistid = 123456789;
  4.     $xmldata = file_get_contents("http://mediaservices.myspace.com/services/media/musicplayerxml.ashx?b=".$artistid);
  5.  
  6.     $xmlartist = simplexml_load_string($xmldata);
  7.  
  8.     echo "Artist: ".$xmlartist->name."<br>";
  9.     echo "Track Listing:<br>";
  10.  
  11.     foreach($xmlartist->playlist->song as $song) {
  12.  
  13.         $xmldata = file_get_contents("http://mediaservices.myspace.com/services/media/musicplayerxml.ashx?b=".$artistid."&s=".$song['bsid']);
  14.         $xmlsong = simplexml_load_string($xmldata);
  15.  
  16.         $temp = explode("?", $xmlsong->curl);
  17.         parse_str($temp[1], $urlinfo);
  18.  
  19.         $songurl = $xmlsong->durl."?bandid=".$urlinfo['bandid']."&songid=".$urlinfo['songid']."&token=".$xmlsong->token."&p=".$urlinfo['p']."&a=0";
  20.  
  21.         echo "Downloading: ".$song['bsid']."<br>";
  22.  
  23.         $mp3data = file_get_contents($songurl);
  24.         $f = fopen("/path/to/save/".$song['bsid'].".mp3", "w+");
  25.         fwrite($f, $mp3data);
  26.         fclose($f);
  27.  
  28.     }
  29.  
  30. ?>

Download: MySpace-MP3-Downloader.zip (1kb)

Life Without Facebook and MySpace

Just recently I deleted my Facebook and MySpace account to see what life is like without them and I love it.

I now have 2 less distractions I need to deal with and I am more productive because of it. I no longer have to respond to comments and messages, I don't have the urge to browse my friend's profiles to see whats going on in their life. Its not that I don't care to know whats going on with them, its that I do it less frequently now and in a more personal manner such as a phone call.

(What? Talking? You mean I have to TALK to my friends? Like using my vocal chords? HA! What about LOL's and smiley faces?)

Get unplugged! I don't see myself going back to Facebook or MySpace anytime soon because I have no need for it right now. For me it was just a waste of time and productivity.

Life Without Facebook and MySpace

Disclaimer: I am an introvert by nature. Yay for me.

WidgetBucks Shopping Widgets

I'm trying out a new ad service called WidgetBucks. So far I am pleased with the ads themselves as they are interactive.

Click here to check it out

Random Password Generator with PHP

This function will generate a random password based off of a character list that you specify. This is very useful for a user registration form.

Example: Instead of asking a user for their desired password on a sign up form, generate a random one for them and email it to them. This poses less of a security risk by emailing them a random password and less fields for them to to fill out when signing up.

PHP:
  1. function randomPassword($length = 7) {
  2.   // empty password
  3.   $password = "";
  4.   // define possible characters
  5.   $possible = "23456789abcdefghjkmnpqrstuvwxyz";
  6.   // add random characters until $length is reached
  7.   $i = 0;
  8.   while ($i <$length) { 
  9.     // pick a random character from the possible ones
  10.     $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
  11.     // don't allow duplicate characters
  12.     if (strpos($password, $char) === false) {
  13.       $password .= $char;
  14.       $i++;
  15.     }
  16.   }
  17.   return $password;
  18. }

List all files in a directory with PHP

This code snippet displays a hyper linked list of all the files contained in a specified folder. I find myself always coming back to this very useful piece of code. I can't count how many times I've used this.

PHP:
  1. <?
  2.     // Define the full path to the folder whose contents you want to list
  3.     $path = "/home/user/public/foldername/";
  4.     // Open the directory
  5.     $dir_handle = @opendir($path) or die("Error opening $path");
  6.     // Loop through the files
  7.     while ($file = readdir($dir_handle)) {
  8.       if($file == "." || $file == ".." || $file == "index.php" ) { continue; }
  9.    
  10.       echo "<a href=\"$file\">$file</a><br />";
  11.     }
  12.     // Close
  13.     closedir($dir_handle);
  14. ?>

RSS Feed



Recommended Sites