#!/usr/bin/php -q $v) { echo "[$k. $v] "; } echo "\n\neg. ".basename($_SERVER['argv'][0])." -t \"blog title\" -c 1,3,4 -k \"php,linux\" -p 0\n"; exit(1); } $options = getopt("c:k:t:p:"); if (empty($options)) { displayHelp(); } // convert categories to array $cat = explode(',',$options['c']); $catList = getCategories(); $categories = array(); foreach ($cat as $v) { $categories[] = $catList[$v]; } // convert tags to array $tag = explode(',',$options['k']); $title = $options['t']; $publish = ($options['p']) ? $options['p'] : 1; $stdin=file_get_contents("php://stdin", "r"); # posting blog $params = array(); $contruct_params = array( 'title'=>$title, 'description'=>"$stdin", 'mt_allow_comments'=>1, 'mt_allow_pings'=>1, 'mt_keywords'=> $tag, 'categories'=> $categories ); $request_params = array( '1', $username, $passwd, $contruct_params, $publish ); $request = xmlrpc_encode_request("metaWeblog.newPost", $request_params); $context = stream_context_create(array('http' => array( 'method' => "POST", 'header' => "Content-Type: text/xml", 'content' => $request ))); $file = file_get_contents($url, false, $context); $response = xmlrpc_decode($file); if (xmlrpc_is_fault($response)) { echo $response['faultString']; exit(1); } else { echo "article posted successfully"; exit(0); } ?>