View Single Post
Old 02-17-2009, 07:08 PM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,520
this basically does what i want it to do, but in perl

Code:
#!/usr/bin/perl -w

use strict;
use Frontier::Client;

my $apikey = 'APIKEYHERE';	
my $src = 'sourcecode.phps'; 
my $title='test post';
my $code = '';
my $tags = 'tag1 tag2 tag3';
my $language = 'php';
my $flag = 0;

open(FC, "<:utf8", $src);
while (<FC>) {
	if (/^\#[^!]\s*(.+)/ && $flag == 0) {
		$title = $1;
		$flag++;
	}
	elsif (/^\#[^!]\s*(.+)/ && $flag == 1) {
		$tags = $1;
		$flag++;
		if (/(\w+) (.+)/) {
			$language = $1;
			$tags = $2;
		}
	}
	$code = $code . $_;
}

my $session = Frontier::Client->new( url => 'http://snipplr.com/xml-rpc.php', debug => 0,);
my @args = ($apikey, $title, $code, $tags, $language);
my $result = $session->call('snippet.post', @args);
the command line version of it using the snipplr ruby gem would be

Code:
snipplr -c -meta ":title=>'test post',:tags=>'tag1 tag2 tag3',:language=> 'php'" < sourcode.phps
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


My Cam Feeds Script / Gallery Scraper / WPXXX Theme / Free Templates
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote