One of my monetization techniques is to use Facebook to drive traffic to a blog. Scheduling the Facebook posts so that they are scattered throughout the day is a time-saver and allows a continued presence, without the need to constantly be on top of it. Initially I used Facebook’s scheduler, but it proved somewhat unreliable as well as clumsy, and also didn’t include other social networks. I tested Hootsuite’s service and liked it, initially.

Hootsuite offers scheduling for several social networks (3 in the free account) and their scheduling process is easier and more dependable than Facebook’s. The problems I ran into, though, caused me to search for an alternative (hard to find) until I finally solved them on my own (no thanks to Hootsuite).

The first problem was in pulling the wrong image. The blog was very image oriented and most posts were nothing but images. However Hootsuite would often pull a random image from the page and ignore the very large, main image. I reduced the odds of this happening by installing the Simple Facebook OG image plugin. This put the <og:image> tag in the header telling any site scraping data which image I wanted them to use. It didn’t solve the problem, but reduced the number of times it happened. Hootsuite would still occasionally ignore the og:image tag and pull a random image.

I finally solved it completely when I learned (through trial and error) that Hootsuite, apparently, doesn’t actually scrape the site itself, but relies of Facebook’s scraping. By going to the Facebook Debugger page, (<=bookmark that) I was able to force the data to be reloaded, and then it would show the correct image at Hootsuite. A word of warning though: every once in a while the Facebook Debugger gets stubborn and will absolutely refuse to load the correct image. Forcing it to reload too many times will cause it to ban you. In my case it was only for a few hours, but I immediately sent an explanation for the repeated reloads, but whether the duration of the ban was shortened by the explanation or automatic, I don’t know.

The second problem I found was that Hootsuite would suddenly decide I was truing to send a private twitter message, instead of schedule an entry. Eventually I figured out that for some odd reason Hootsuite will take any entry that beginning with one letter, then a space as a private twitter message. I have no idea why they do this, but by starting your entry with a space, it then treated it as an entry. That’s only needed for an entry that begins with a letter, then a space (such as “A is for…”)

Hootsuite was absolutely no help at all in solving these problems, so posting it here will hopefully make it available for anyone searching for a solution.

We’ve added a new page: http://wp-functions.blogscripting.com/

While all these functions are at http://codex.wordpress.org, they are a bit hard to sort through. The best reference sources are ones that provide a quick and easy way to locate specific items. We’ve included a nice, intuitive location menu to help locate the specific function you are looking for. Hope you enjoy.

Okay, it’s not blogging, but it took me forever to track down how to do this, so I figured I’d post it for others to use.

The setting: An ecommerce site.
The need: Searching for items in the inventory, but returning the same result whether the search terms are singular or plural, without messing up an exact phrase.
The solution: create two sets of keywords, singular and plural and search both literal and for the individual words via a regular expression.

I’m sure there are more efficient ways of doing this, but I couldn’t find any, and this is what I cam up with.

//$get_search is the search keyword(s) submitted via a
//  GET and filtered to block any hacking attempts

// $catSort is the sort criteria 'relevance',
//    'price:lo to hi', 'price:ho to lo', etc.
  $catSort=$_GET['catSort'];
  if(!$catSort){$catSort='relevance'; $order=' ORDER BY `rel` DESC';}
  $itemsPerPage=$_GET['itemsPerPage'];
  if(!$itemsPerPage){$itemsPerPage='20';}
  if($catSort=='l2h'){$order=' ORDER BY `price` ASC';}
  if($catSort=='h2l'){$order=' ORDER BY `price` DESC';}
  if($catSort=='item'){$order=' ORDER BY `productname`';}

//clean up the keyword some
  $get_search=rtrim(ltrim(urldecode($get_search

//  this array helps converts the key word (or last keyword in a phrase) to the plural form
$plural_rules = array(
'/(x|ch|ss|sh)$/' => '\1es',            # search, switch, fix, box, process, address
'/series$/' => '\1series',              #series is the same
'/([^aeiouy]|qu)y$/' => '\1ies',        # query, ability, agency
'/(?:([^f])fe|([lr])f)$/' => '\1\2ves', # half, safe, wife
'/sis$/' => 'ses',                      # basis, diagnosis
'/ex$/' => 'ices',                      # index
'/([ti])um$/' => '\1a',                 # datum, medium
'/person$/' => 'people',                # person, salesperson
'/man$/' => 'men',                      # man, woman, spokesman
'/foot$/' => 'feet',
'/louse$/' => 'lice',
'/mouse$/' => 'mice',
'/tooth$/' => 'teeth',
'/child$/' => 'children',
'/([nti])on$/' => 'a',                  # criterion
'/(.*)status$/' => '\1statuses',
'/s$/' => 's',                          # no change (compatibility)
'/$/' => 's'                            # everything else
);

//  this array helps converts the key word (or last keyword in a phrase) to the singular form
$singular_rules = array(
'/(xes|ches|sses|shes)$/e' =>           # the /e allows an executable phrase within the replacement
    "str_replace('es','',$1)",          # boxes, classes
'/series$/' => 'series',
'/([^aeiouy]|qu)ies$/' => '\1y',
'/([lr])ves$/' => '\1\2f',              # halves, scarves
'/([^f])ves$/' => '\1fe',               # wives
'/ses$/' => 'sis',                      # bases, diagnoses
'/ices$/' => 'ex',                      # indices
'/([ti])a$/' => '\1um',                 # data, media
'/people$/' => 'person',                # people, salespeople
'/men$/' => 'man',                      # men, women, spokesmen
'/feet$/' => 'foot',
'/lice$/' => 'louse',
'/mice$/' => 'louse',
'/teeth$/' => 'tooth',
'/children$/' => 'child',
'/([nti])a$/' => 'on',                  # criteria
'/(.*)statuses$/' => '\1status',
'/[aious]s$/' => '',                    # no change (compatibility)
'/s$/' => ''                            # everything else that ends in an 's'
);

$string=$get_search;
$match=false;
foreach($plural_rules as $pattern => $replacement)
  {
  if(!$match and preg_match($pattern, $string))
    {
    $out=preg_replace($pattern, $replacement, $string);
    $match=true;
    }
  }
if($out and $out!=$get_search){$plural=$out;}
else{$plural=$get_search;}

$match=false;$out='';
foreach($singular_rules as $pattern => $replacement)
  {
  if(!$match and preg_match($pattern, $string))
    {
    $out=preg_replace($pattern, $replacement, $string);
    $match=true;
    }
  }
if($out and $out!=$get_search){$singular=$out;}
else{$singular=$get_search;}
}

// the regexp will crash if we send it an empty
//   variable. So we do this
if(!$get_search){$get_search='[[[]]]';}

//I typical throw in a capital letter to distinguish
//  arrays from variables
$get_Search=explode(' ',$get_search);

//Yes, I know there's an easier way to weed out repeated
//   spaces, but I was in a hurry
$Temp='';
foreach($get_Search as $el)
  {
  if($el){$Temp[]=$el;}
  }
$get_Search=$Temp;

//we include all the keywords for the regexp part
$regexp=implode('|',$get_Search);

//these cell names are samples
// the first part (with all the IFs) allows us to create a
//   relevance score, customized to weight the individal
//   cells searched. We place a lot of weight on an exact
//   name match. and we do it once for the singular form
//   and once for the plural form and once for the regexp.
// $order we set previously so the search can be ordered
//   by price, item name or relevance
  $queryText = sprintf("
SELECT `productid`,
 IF(`productname` LIKE '%%%s%%',20,0)
+IF(`description` LIKE '%%%s%%',4,0)
+IF(`manufacturer` LIKE '%%%s%%',1,0)
+IF(`productcode` LIKE '%%%s%%',1,0)
+IF(`productname` LIKE '%%%s%%',20,0)
+IF(`description` LIKE '%%%s%%',4,0)
+IF(`manufacturer` LIKE '%%%s%%',1,0)
+IF(`productcode` LIKE '%%%s%%',1,0)
+IF(`productname` REGEXP '[[:<:]]%s[[:>:]]' ,2,0)
+IF(`description` REGEXP '[[:<:]]%s[[:>:]]' ,2,0)
+IF(`manufacturer` REGEXP '[[:<:]]%s[[:>:]]' ,1,0)
+IF(`productcode` REGEXP '[[:<:]]%s[[:>:]]' ,1,0) AS `rel`
FROM `ecommerce_products`
WHERE (`productname` LIKE '%%%s%%'
   OR `description` LIKE '%%%s%%'
   OR `manufacturer` LIKE '%%%s%%'
   OR `productcode` LIKE '%%%s%%'
   OR `productname` LIKE '%%%s%%'
   OR `description` LIKE '%%%s%%'
   OR `manufacturer` LIKE '%%%s%%'
   OR `productcode` LIKE '%%%s%%'
   OR `productname` REGEXP '[[:<:]]%s[[:>:]]'
   OR `description` REGEXP '[[:<:]]%s[[:>:]]'
   OR `manufacturer` REGEXP '[[:<:]]%s[[:>:]]'
   OR `productcode` REGEXP '[[:<:]]%s[[:>:]]') $order;
",
         mysql_real_escape_string($plural),
         mysql_real_escape_string($plural),
         mysql_real_escape_string($plural),
         mysql_real_escape_string($plural),
         mysql_real_escape_string($singular),
         mysql_real_escape_string($singular),
         mysql_real_escape_string($singular),
         mysql_real_escape_string($singular),
         mysql_real_escape_string($regexp),
         mysql_real_escape_string($regexp),
         mysql_real_escape_string($regexp),
         mysql_real_escape_string($regexp),
         mysql_real_escape_string($plural),
         mysql_real_escape_string($plural),
         mysql_real_escape_string($plural),
         mysql_real_escape_string($plural),
         mysql_real_escape_string($singular),
         mysql_real_escape_string($singular),
         mysql_real_escape_string($singular),
         mysql_real_escape_string($singular),
         mysql_real_escape_string($regexp),
         mysql_real_escape_string($regexp),
         mysql_real_escape_string($regexp),
         mysql_real_escape_string($regexp));

// I use a db link variable to allow error messages
  $query=mysql_query($queryText, $link);
  if(mysql_errno($link)){echo ": " . mysql_error($link) . "\n<hr>";}

  if(mysql_num_rows($query))
    {
    while ($dbRow = mysql_fetch_array($query))
      {
      $id=$dbRow[0];
// this is to weed out duplicates
      $return[$id]++;
      }

// this creates a nice array of product ids for us to work with.
// using only the product ids we can begin with the entire list,
//   without over burdening the server
// from here we simply grab the ones we need (based on the
//    start # and pagelength #)
// using the product id, I use a function that then grabs
//    all the pertinent data about that item.
  foreach($return as $key=>$value)
    {
    $prodList[]=$key;
    }

The term “mash up” has emerged in recent year. It means using various data from differing sources. Sort of like showing a google map of the locations of those tweeting you. The map comes from google, the tweeets come from twitter and when you put them together it’s a mash up.

So, in that light I wanted to list sources of data/functionality that you can pull into your blog to mash up what you offer your readers.

http://YouTube.com
http://mediaplayer.yahoo.com/
Google Maps
Twitter
Facebook

MySpace

Both MT and WP offer a feed which can be set to a full feed or just an excerpt. Blogger who rely on ad revenues will generally choose just an excerpt, while bloggers who are more focused on getting their stuff read will offer a full feed. Then there are the other 99% of bloggers who don’t know what feeds are.

For those, let me give a quick explination. The feed would be the bare-bones info of your blog. The title, author and text (exeprpt or full) that in in a format easy to process by scripts. At my site http://new.elevenoclock.comI use the feeds provided by many news sources as well as blogs to display the current headlines.  News readers like Eleven O’clock News, Google Reader (http://google.com/reader ), and http://BlogLines.com use the feed from your blog to show the content to others. If you just like people reading your stuff, then that would be okay. But if you want people to go to your site, then you’d offer only an excerpt so to finish the article they’d need to come to your site.

One of the most important things about feeds, if you want people to use them, is to make them handy, and display the link to your feed somewhere where it’s easy to find. Typically it’s either at the top or the bottom of the page, but sometimes it’ll be in the sidebar. It’s also, typically, included in the header of the page so scripts can pick the link up there.

Some blogs (and online newspapers) have gone even further than limiting the content, and insert ads into the feeds themselves. That’s perhaps a bit stingy, especially if you’re only offering an excerpt to begin with, but it’s what they choose to do.

About me

I've been developing web sites for over 12 years. I started with HTML, moved on to Perl and now do mostly PHP with a lot of MySQL and Javascript as well.

The purpose of this blog is to write about many of the simpler scripting solutions bloggers are either unaware of or unable to implement. Hopefully I'll have something you can use

Danny Carlton

Advertising
Advertising