Creating a wordpress website via xml-rpc using affiliate data feeds

Having looked up on the web for some help to create a wordpress website that submits posts by reading from affiliate data feeds, finally came up with a script that works just fine. This script uses the xml-rpc support of wordpress api provided with the installation.

There are many advantages to using a wordpress based website to run your website with affiliate links. One of them is search engine optimization. It’s easy to manage categories of your products. It takes out the pain of designing a website. A wide range of templates are available free of cost to choose from. Pick one that would best suit your products.

If you do not like to get your hands muddy, there’s a service I would like to recommend - DataFeedr. Just look at their extremely happy customer testimonials. If your time is more precious than a few dollars a month, I recommend using DataFeedr instead of getting your hands dirty. The time you save will earn you more dollars.

Anyway, without digging too much into details, copied below script for your use. If you find this useful, I request you to place a link to this page on your website. I have attached a sample of the data feed, the script AddNewWordpressPost.php that I used to generate the wordpress blogs automatically using xml-rpc support.

<?php

include(”../wp-includes/class-IXR.php”);

function add_post($title,$description,$categories,$tags)

{

$client = new IXR_Client(’http://<enter your website url here or localhost>/xmlrpc.php’);

echo $client->getResponse();

$content['title'] = $title;

$content['description'] = $description;

$content['categories'] = $categories;

$content['mt_keywords'] = $tags;

if (!$client->query(’metaWeblog.newPost’,”, ‘<enter your wordpress userid which has privilege to write blog>’,'<enter your wordpress website password>’, $content, true)) {

die(’An error occurred - ‘.$client->getErrorCode().”:”.$client->getErrorMessage());

}

echo $client->getResponse() . “\n” ;

}

$row = 1;

if (($handle = fopen(”../data/data_feed.txt”, “r”)) != FALSE) {

while (($data = fgetcsv($handle, 2048, “\t”)) !== FALSE) {

$title=$data[9]; //product_name

$description=$data[10];

$specification=$data[11];

$tags[0]=$data[12];

$category[0]=$data[14];

$deeplink=$data[20];

$prod_image=$data[22];

$currency=$data[26];

$price=$data[27];

echo $title . ‘\n’;

echo $description . “\n”;

echo $specification . “\n”;

echo ‘Tag: ‘. $tags[0] . “\n”;

echo ‘Category: ‘ . $category[0] . “\n”;

echo $title . “\n”;

echo $deeplink . “\n”;

echo $prod_image . “\n”;

echo $currency . “\n”;

echo $price . “\n\n”;

// Prepare description

$desc = ‘<a href=”‘ . $deeplink . ‘” target=”_blank”><img class=”alignleft” title=”‘ .

$title . ‘” src=”‘ . $prod_image . ‘” alt=”‘ . $title . ‘” width=”200″ height=”200″ /></a></br></br>’ .

‘<p>’ . $description . ‘</p>’ .

‘<p>’ . $specification . ‘</p>’ .

‘<p><b>Price: ‘ . $currency . ‘ ‘ . $price . ‘ : <a href=”‘ . $deeplink .

‘” target=”_blank”>Gift Now</a></b></p>’;

//echo $desc;

add_post($title,$desc,$category,$tags);

$row++;

}

fclose($handle);

}

?>

data_feed.txt

The pre-requisites are that:

From the script directory where you have placed, run php AddNewWorpressPost.php. I ran this on a Linux server with apache and php pre-installed.

That will start posting the data to your website. Take a look at http://gift-an-experience.co.cc which is the website created using this script. Share your thoughts.

As I requested earlier, if you found this useful, please feel free to share the link. Cheers.

If you do not like to get your hands muddy, there’s a service I would like to recommend - DataFeedr. Check them out.

Written by Home Worker on November 29th, 2011 with no comments.
Read more articles on Work from home.

Related articles

No comments

There are still no comments on this article.

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:

You have to be identified to write a comment.