Archive for March, 2009

2
Mar

One of the aspects of BHSEO with Affiliate Marketing in mind is data integration. This could be from RSS feeds to straight XML files, even just research on one product and finding offshoots yourself. I haven’t given away any “stunning” code lately (or any for that matter …) so I figured I’ll release a little [...]

One of the aspects of BHSEO with Affiliate Marketing in mind is data integration. This could be from RSS feeds to straight XML files, even just research on one product and finding offshoots yourself. I haven’t given away any “stunning” code lately (or any for that matter …) so I figured I’ll release a little source here to help you all along with automation. I’m going to keep the post here short and sweet, and let you all use your imagination with the code itself but I’ll give you a few unique uses for it.

Before I start telling you how to use it, here’s what you need – and what you may want to have.

What you NEED:

  • PHP 5
  • WordPress
  • Desire to Learn and Think Abstractly

What you may want (and will help …)

  • phpBay
  • WFReview
  • (these will be at the end of the post as well so you can decide AFTER you see why)

Here’s a few things to think about with the code …

  • This uses XMLRPC so will work with Splog Ping Crawl
  • Can be integrated with Google Blog Search for avoiding duplicate content penalties *hint hint*
  • Can be used full steam, throttled back, etc.

Now I’m going to admit this right now. It’s 3:15 in the morning right now and I’m tired as hell – but I did want to get this out because I promised a few of you I would get it done. So please forgive me if the code itself isn’t so clean, but my goal is purely to prove it can be done – and it’s not too hard to do either. My goal here on Contempt is to help you re-think about Automation in general and help you create ways to make your online endeavours much easier. For some Automation in general is considered blackhat, and to those people I’d like to remind them to wake up. Everything in life is getting automated whether you like it or not. Personally in my opinion blackhat seo is nothing other than a label for “holy shit that’s automatic”. Usually this is by people that don’t know how to do it, or have a problem looking at their newfound power and ability and can’t control it enough to not go overboard. This usually results in “i can spam links, go buy viagra go!”. It’s true – the same methods that I use sometimes could be used as an attempt to rank for buy viagra – and you know what, I’m sure with some time I could – but why? I want long term residual income off my endeavours, and right now I’m doing enough research to plan the methods down to successful ones so I don’t make stupid mistakes over and over on sites I’ve invested money into.

Anyway – like I said – It’s 3:30 so I’m ranting. Let’s move on. Here’s my overall goal with this post. In the following code I’m going to show you very simple code to extract information from a CSV, and how to format it into a good post for a review or shopping site. Here’s how you do that using PHP5 ..

<?php
$row = 1;
$handle = fopen("datafeed.csv", "r");
while (($data = fgetcsv($handle, 5000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo "$c - ".$data[$c] . "<br />\n";
}
if($row > 5)
die();
}
fclose($handle);
?>

I wrote this up quick to view the first 5 rows in a datafeed file. This’ll allow me to look at (with most feeds) the names of the fields, and then the first 4 lines to see sample data. This is an easy way to sort out “oh #5 is the URL” and “#10 is the image”. Next we’ll work on a template file so that when we post it to wordpress it’ll at least look decent. I’m not going to say my HTML is stellar, but I’m doing this as I write this so it’s purely an example. Here’s an example with a quick table, 2 sections – image and purchase URL on the left, description on the right … and of course, phpbay under it haha – Contempt style!

<?php
$row = 1;
$handle = fopen("datafeed.csv", "r");
while (($data = fgetcsv($handle, 5000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
$purchase_url = $data[8];
$image = $data[25];
$desc = $data[12];
$title = $data[16];
$var = "<center><table width=\"50%\"><tr><td>
<a href=\"$purchase_url\"><img src=\"$image\">
</a></td><td>$desc</td></tr></table><br><br>
Used Items:<br><br>[phpbay]$title, 10[/phpbay]";
echo $var."<BR><BR><BR><BR>";
if($row > 5)
die();
}
fclose($handle);
?>

And just so you all have this, here’s the function that I use to post to WordPress blogs with XMLRPC. The external libs I’ll throw into a RAR (click here). Here’s the function:

<?php
function post_to_blog($url, $pass, $title, $posttext, $nick = null)
{
$xmlrpcurl = $url;
$client = new xmlrpc_client($xmlrpcurl);
$params[] = new xmlrpcval("n/a");
$params[] = new xmlrpcval("n/a");
if(isset($nick))
$params[] = new xmlrpcval("$nick");            //your wordpress login
else
$params[] = new xmlrpcval("Admin");            //your wordpress login
$params[] = new xmlrpcval("$pass");        //your wordpress password
$params[] = new xmlrpcval(
"<title>$title</title>".            //the title of your post
"<category>1</category>".    //the category
$posttext);                                 //the body
$params[] = new xmlrpcval("true");          //publish now = true
$msg    = new xmlrpcmsg("blogger.newPost",$params);
$response = $client->send($msg);
}
?>

So yeah, when we put them together we have this…

<?php
$row = 1;
$handle = fopen("datafeed.csv", "r");
while (($data = fgetcsv($handle, 5000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
$purchase_url = $data[8];
$image = $data[25];
$desc = $data[12];
$title = $data[16];
$var = "<center><table width=\"50%\"><tr><td>
<a href=\"$purchase_url\"><img src=\"$image\">
</a></td><td>$desc</td></tr></table><br><br>
Used Items:<br><br>[phpbay]$title, 10[/phpbay]";
post_to_blog("http://myblog.com/xmlrpc.php", "password", $title, $var);
if($row > 5)
die();
}
fclose($handle);
function post_to_blog($url, $pass, $title, $posttext, $nick = null)
{
$xmlrpcurl = $url;
$client = new xmlrpc_client($xmlrpcurl);
$params[] = new xmlrpcval("n/a");
$params[] = new xmlrpcval("n/a");
if(isset($nick))
$params[] = new xmlrpcval("$nick");            //your wordpress login
else
$params[] = new xmlrpcval("Admin");            //your wordpress login
$params[] = new xmlrpcval("$pass");        //your wordpress password
$params[] = new xmlrpcval(
"<title>$title</title>".            //the title of your post
"<category>1</category>".    //the category
$posttext);                                 //the body
$params[] = new xmlrpcval("true");          //publish now = true
$msg    = new xmlrpcmsg("blogger.newPost",$params);
$response = $client->send($msg);
}
?>

So there you have it. Loading a CSV file into wordpress with a template, to start up your own affiliate-based eStore. Once again I thank you for joining me on this Code-Enriched version of Contempt Can’t Sleep. I figured keeping this short and sweet would be more beneficial than posting with fluff and other dumb crap to try to impress you.

The reason I recommended phpBay is because of the fact that it’ll allow you to post direct links from PJN (PepperjamNetwork) or EPN (eBay Partner Network) with the new items. New & Used. The WFReview will actually allow people to rate the items, comment on them with star ratings, and post random generated ratings on them to make the site look like a good well traffic’d site. A must have for larger scale op’s and just fun in general! This also is an easier way to automate the CSV to WordPress operation. So once again, those links are in this paragraph if you wanted to try those out.

I hope you enjoyed the read as well as the Contempt experience, and I hope it’s worthy enough to have you pull the trigger on subscribing to the feed!

1 Star2 Stars3 Stars4 Stars5 Stars (9 votes, average: 3.89 out of 5)
Loading ... Loading ...
Categories : Affiliate Marketing,Blackhat Explained,Blog Automation,SEO/SEM Tags : , , , , ,