So I love and use services like Lalit_Burma or Red_Virus's social bookmarking, but I HATE writing the orders. Writing tags, descriptions, titles, etc. So much that I put off getting my linkbuilding going because of it.
Half of the crap I like to use is already in the meta tags, so I made myself a script to help out. It reads a CSV File, with these fields:
URL # Bookmarks (20, 40,60, 100) Title(s) Use Page Title? Additional Descriptions Category Additional Tags
It then pulls in the meta keywords (for tags), descriptions (semicolon delimited), and other titles you want
Run it from the command line using php -e GenerateSocialBookmarkOrders.php (if you want to run it from the browser you'll have to get rid of the STDIN stuff).
It dumps it to a txt file. Could easily dump it to the screen too.
I still want to completely automate the process of social bookmarks using a web-based language like watir/watin/imacros/etc... and have an odesk job with a few applicants, but haven't fully jumped into it. THat's discussed here.
Note the best coder so no making fun. It works.
Half of the crap I like to use is already in the meta tags, so I made myself a script to help out. It reads a CSV File, with these fields:
URL # Bookmarks (20, 40,60, 100) Title(s) Use Page Title? Additional Descriptions Category Additional Tags
It then pulls in the meta keywords (for tags), descriptions (semicolon delimited), and other titles you want
Run it from the command line using php -e GenerateSocialBookmarkOrders.php (if you want to run it from the browser you'll have to get rid of the STDIN stuff).
It dumps it to a txt file. Could easily dump it to the screen too.
I still want to completely automate the process of social bookmarks using a web-based language like watir/watin/imacros/etc... and have an odesk job with a few applicants, but haven't fully jumped into it. THat's discussed here.
Note the best coder so no making fun. It works.
Code:
<?php
/**
* Generate Social Bookmarks - by Berto
* http://www.wickedfire.com/members/berto.html
*
* This file will read SocialBookmarkOrderForm.csv and create an order form
* for people like Lalit_Burma. It will open the URL, get title and meta
* information, look at our order form's extra input, and create a .txt
* file for an order.
*
* Use: run from command line using php -e GenerateSocialBookmarkOrders.php
*
* Inputs: 1. Will prompt for order name to create a file
* 2. Row 0: URL
* 3. Row 1: # Bookmarks (Typically 100, 60, 40, or 20)
* 4. Row 2: Title(s) - Comma separated list of titles
* 5. Row 3: Use Page Title? Y or N ... if Y, it will add URL's Title
* 6. Additional Descriptions: Add more descriptions, separated by semicolons.
* (These are in addition to the meta description)
* 7. Category: The main category
* 8. Additional Tags: On top of whatever is in the meta keywords.
*
* Outputs:
* Will create YourOrderName.txt with a list of data from above
* Will also output any SEO page errors, such as No Title, or no Meta tags
*/
// Open input file or die
$filename = "SocialBookmarkOrderForm.csv";
$inputFileHandle = fopen($filename, "r");
if(!$inputFileHandle) {
echo "Error: Cannot Open SocialBookmarkOrderForm.csv";
return;
}
fwrite(STDOUT, "Please enter the order name: ");
$orderName = preg_replace('/\s+/','',fgets(STDIN));
$outputFileHandle = fopen($orderName."-SocialBookmarkOrder.txt", "w"); /
/ Currently overwrites
if(!$outputFileHandle) {
echo "Error: Cannot Open $orderName-SocialBookmarkOrder.txt for
writing";
return;
}
$headerLine = fgetcsv($inputFileHandle); // Trash this...
$counter = 1;
while( ($thisLine = fgetcsv($inputFileHandle)) !== FALSE) {
$url = trim($thisLine[0]);
$titles = array();
$descriptions = array();
$categories = array();
$tags = array();
echo "URL: $url\n";
// Start by pulling any info from the URL...
$urlTags = get_meta_tags($url);
$tags = explode(',', $urlTags['keywords']);
$descriptions[] = $urlTags['description'];
// Grab the URL's Title if Requested
// WARNING - This will be the second time downloading the URL..
.
if(strncasecmp($thisLine[3],'y',1) == 0) { // Compare first char
, case-i
$urlContents = file($url);
$urlContents = implode("",$urlContents);
preg_match("/<title>(.+)<\/title>/i",$urlContents,$match
es);
if(!empty($matches)) {
$titles[] = $matches[1];
} else {
echo "WARNING: $url has no title\n";
}
}
$numBookmarks = trim($thisLine[1]);
if(!empty($thisLine[2])) {
$titles = array_unique(array_merge($titles, explode(',',
$thisLine[2])));
}
array_walk($titles, 'trim_array');
// print_r($titles);
if(!empty($thisLine[4])) {
$descriptions = array_unique(array_merge($descriptions,
explode(';', $thisLine[4])));
}
array_walk($descriptions, 'trim_array');
// print_r($descriptions);
$categories = trim($thisLine[5]); // Just leave it however I wri
te it..
if(!empty($thisLine[6])) {
$tags = array_unique(array_merge($tags, explode(',', $th
isLine[6])));
}
array_walk($tags, 'trim_array');
shuffle($tags);
// print_r($tags);
fwrite($outputFileHandle, "Item " . $counter . ".\n\n - URL: $ur
l\n\n");
foreach($titles as $i => $title) {
fwrite($outputFileHandle, " - Title $i - " . $title . "\
n");
}
fwrite($outputFileHandle, "\n");
foreach($descriptions as $i => $description) {
fwrite($outputFileHandle, " - Description $i - " . $desc
ription . "\n");
}
fwrite($outputFileHandle, "\n");
fwrite($outputFileHandle, " - Category - " . $categories . "\n\n
- Tags - ");
$tagOutput = implode($tags, ', ');
fwrite($outputFileHandle, "$tagOutput\n\n");
$counter++;
}
fclose($inputFileHandle);
fclose($outputFileHandle);
function trim_array(&$value) {
// From http://php.net/manual/en/function.trim.php
$value = trim($value);
}
?>