Sunday, March 25, 2007

Automatic Keyword Generation

I posted a while back about the Automatic Keyword Generator PHP class by Ver Pangonilo. This works pretty well, but can only find keywords based on the text you input. It cannot generate related terms, synonyms, etc. However, the Yahoo Content Analysis Web Service can do all these things and more.

You can generate these keywords using the following function:

function implodeAssoc($array, $inner_glue='=', $outer_glue='&') {
$output = array();
foreach( $array as $key => $item ){
$output[] = $key . $inner_glue . $item;
}
return implode($outer_glue, $output);
}

function getKeywords($text) {
$baseurl = 'http://search.yahooapis.com/ContentAnalysisService/V1/termExtraction';
$params = array('appid'=>'YahooDemo',
'context'=>urlencode($text),
'output'=>'php');

$request = $baseurl . '?' . implodeAssoc($params);
$xml = file_get_contents($request);
$result = unserialize($xml);
$keywords_array = $result['ResultSet']['Result'];
$keywords = implode(",",$keywords_array);
return($keywords);
}

echo getKeywords("Bill Gates to Finally Receive His Harvard Degree. It's not like he needs it to beef up his resume, but the world's richest college dropout is finally getting his degree. Bill Gates, chairman of Microsoft Corp.");


This will output:
bill gates,harvard degree,microsoft corp,college dropout,resume

Tuesday, October 31, 2006

Interprise Suite v1

I've been following Interprise Suite for the last 18 months or so. I was a beta tester for a while, but I grew tired of waiting around for their release (originally scheduled for late 2005). They just unofficially put out their first release. You can get it here: http://www.interprisesolutions.com/Forum/Topic3911-57-5.aspx#bm3978

I haven't really messed with the software yet, but I hope to use it to start a drop shipping business.

Monday, October 23, 2006

Viral Marketing with phpList

I've been messing around a lot with phplist. It is a fullfledged newsletter manager with a double opt-in subscription mechanism, scheduling, RSS, click-tracking, attachments and bounce management. The plan is to create a viral marketing script that uses the PHPList database to control user access to the member areas of the site.

I'm also trying to incorporate the GeoLite City database, so I can capture a users region when they sign up for the newsletter. Since the niche I'm working in is very location oriented, I hope to be able to use PHPList and PHPadsnew to target them with location specific newsletters and banners.

I'm going to try the plan similar to the 15kchallenge. The plan is to offer something for free if they add their email address, and confirm using the link in the welcome email. Then offer something else for free if they sign up 3 friends (and they confirm).

Thursday, October 19, 2006

Amazon API IntelliTXT

I'm sure other people have done this, but I created a script that injects Amazon products (w/ new product previews) into articles similar to the way IntelliTXT works. I use the automatic keyword class from previous posts to find keywords in an article, search the Amazon API with those keywords, and then replace the keywords in the article with the newly created link. It seems to work fairly well. Mouse over the links in this post to see how the Amazon Previews work.


//To use this you'll need to first download tools.inc.php
//which is included with the AWS Book (awsbook.com)
//samples.
//http://sourceforge.net/project/showfiles.php?group_id=88612
//Find tools.inc.php under 'Chapter 4'
//
require_once("tools.inc.php");
define('SUBID', '1A7XKHR5BYD0WPJVQEG2'); // Your subscription id

define('Searchindex','Books');
//define('Searchindex','Music');
//define('Searchindex','DVD');
//define('Searchindex','Toys');
//define('Searchindex','Video Games');
//define('Searchindex','Software');
//define('Searchindex','Software Video Games');
//define('Searchindex','Electronics');
//define('Searchindex','Tools');
//define('Searchindex','Sporting Goods');
//define('Searchindex','Art Supplies');
//define('Searchindex','Kitchen');
//define('Searchindex','Gourmet Food');
//define('Searchindex','Apparel');
//define('Searchindex','PC Hardware');
//define('Searchindex','VHS');

function awsreplace($keyword) {
$request = 'http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId='.SUBID.'&Operation=ItemSearch&Keywords='.urlencode($keyword).'&SearchIndex='.Searchindex.'&Sort=salesrank';
// Get the response from Amazon
$xml = file_get_contents($request);
// Parse the results
$Result = xmlparser($xml);
$ASIN = $Result['ItemSearchResponse']['Items'][0]['Item'][0]["ASIN"][0];
$url = '<a href="http://www.amazon.com/gp/product/'.$ASIN.'?ie=UTF8&tag=duelcoastweb-20&linkCode=as2&camp=1789&creative=9325&creativeASIN='.$ASIN.'">';
$replacestr = $url . $keyword . '</a>';
if (!isset($Result['ItemSearchResponse']['Items'][0]['Item'][0]["ASIN"][0])) {
$replacestr = $keyword;
}
return $replacestr;
}


I call the function from within my page like this:

foreach ($keyword_array AS $keyword_replace) {
$body = str_ireplace(trim($keyword_replace),awsreplace(trim($keyword_replace)),$body);
}
?>

Saturday, October 14, 2006

AIS Script Finished

I finished my Smarty script. Complete with automatic keywords, SEO URLs, valid xhtml. The speed is great, and there is no need for a database. Just upload the articles, no other configuration needed. I'll be setting up all of the domains I lost when I was hacked over the next few days with the new script.

The only problem I am having with Smarty is with the caching feature. I cannot figure out how to make Smarty see a script with parameters (i.e. smarty.php?a=1) as its own file. Right now it is caching the page as 1 file, regardless of if the parameters are different. If anyone knows how to solve this problem with Smarty, please let me know. Right now, I have cache turned off.