Location: PHPKode > scripts > Freshmeat.net XML-RPC > freshmeat-net-xml-rpc/freshmeat.class.php
<?php

include("xmlrpc.php");

/**
 * freshmeat class : FRESHMEAT.NET XML-RPC API VERSION 1.02
 * 
 * @package 
 * @author Ben Yacoub Hatem <hide@address.com>
 * @link	http://freshmeat.net/faq/view/49/	Description of the XML-RPC service
 * @link	http://www.dynamix-tn.com/ Dynamix SARL
 * @copyright Copyright (c) 2004
 * @version $Id$ - 20/02/2004 15:49:10 - freshmeat.class.php
 * @access public
 **/
class freshmeat{
	/**
     * Constructor
     * @access protected
     */
	function freshmeat(){
		
	}
	
	/**
	 * Fetch all available licenses
	 * 
	 * @access public
	 * @param none
	 * @return Array of available licenses
	 **/
	function fetch_available_licenses(){

		$f = new xmlrpcmsg('fetch_available_licenses');
		return freshmeat::q($f);
	}
	
	/**
	 * Fetch all available release focus types
	 * 
	 * @access public
	 * @param none
	 * @return Struct of available release focus types and associated IDs

	 **/
	function fetch_available_release_foci(){
		$f = new xmlrpcmsg('fetch_available_release_foci');
		return freshmeat::q($f);
	}
	
	/**
	 * Fetch all branch names and IDs for a given project 
	 * 
	 * @param string $SID	Session ID to work with
	 * @param $project_name	Project name to fetch branches for
	 * @return 	Array of branch name strings.
	 **/
	function fetch_branch_list($SID = "",$project_name = ''){
	
		$f=new xmlrpcmsg('fetch_branch_list', array(new xmlrpcval($SID, "string"),new xmlrpcval($project_name, "string")));
		return freshmeat::q($f);
	}

	/**
	 * Fetch data from a pending release submission
	 * 
	 * @param string $SID	Session ID
	 * @param string $project_name	Project name
	 * @param string $branch_name	Branch name
	 * @param string $version	Release version string
	 * @return Struct consisting of "version", "changes", "release_focus", and "hide_from_frontpage"
	 **/
	function fetch_release($SID,$project_name,$branch_name,$version){
		$f=new xmlrpcmsg('fetch_release', array(new xmlrpcval($SID, "string"),new xmlrpcval($project_name, "string"),new xmlrpcval($branch_name, "string"),new xmlrpcval($version, "string")));
		return freshmeat::q($f);
	}
	
	
	/**
	 * Start an XML-RPC session
	 * 
	 * @param $username	Regular freshmeat username
	 * @param $password	Regular freshmeat password
	 * @return 	Struct of SID, lifetime, and API Version
				SID: Session ID to be used in subsequent requests to the XML-RPC service
				Lifetime: Lifetime of the session ID in seconds
				API Version: API Version currently in use
	 **/
	function login($username,$password){
		$f=new xmlrpcmsg('login', array(new xmlrpcval($username, "string"),new xmlrpcval($password, "string")));
		return freshmeat::q($f);
	}
	

	/**
	 * End an XML-RPC session
	 * 
	 * @param string $SID
	 * @return Struct of "OK" => "Logout successful." if logout was successful
	 **/
	function logout($SID = ""){
		$f=new xmlrpcmsg('logout', array(new xmlrpcval($SID, "string")));
		return freshmeat::q($f);
	}
	
	/**
	 * Publish a new release
	 * 
	 * @param $SID			Session ID to work with
	 * @param $project_name	Project name to submit a release for
	 * @param $branch_name	Branch name to submit a release for
	 * @param $version		Version string of new release
	 * @param $changes		Changes list, no HTML, character limit 600 chars
	 * @param $release_focus	Release focus ID of new release :
	 * 0 - N/A
	 * 1 - Initial freshmeat announcement
	 * 2 - Documentation
	 * 3 - Code cleanup
	 * 4 - Minor feature enhancements
	 * 5 - Major feature enhancements
	 * 6 - Minor bugfixes
	 * 7 - Major bugfixes
	 * 8 - Minor security fixes
	 * 9 - Major security fixes
	 * 
	 * @param $hide_from_frontpage	Set to 'Y' if release is to be hidden from frontpage, everything else does not hide it
	 * @param $license		Branch license
	 * @param $url_homepage	Homepage
	 * @param $url_tgz		Tar/GZ
	 * @param $url_bz2		Tar/BZ2
	 * @param $url_zip		Zip
	 * @param $url_changelog	Changelog
	 * @param $url_rpm		RPM package
	 * @param $url_deb		Debian package
	 * @param $url_osx		OS X package
	 * @param $url_bsdport	BSD Ports URL
	 * @param $url_purchase	Purchase
	 * @param $url_cvs		CVS tree (cvsweb)
	 * @param $url_list		Mailing list archive
	 * @param $url_mirror	Mirror site
	 * @param $url_demo		Demo site
	 * @return 	Struct of "OK" => "submission successful"
	 * Notes: The "license" and "url_*" fields are optional and will be taken from the branch record if they
	 * are omitted from the submission. The 'hide_from_frontpage' option can be omitted an defaults to
	 * 'do not hide'.
	 **/
	function publish_release($SID,$project_name,$branch_name,$version,$changes,$release_focus,$hide_from_frontpage,$license = '',$url_homepage = '',$url_tgz = '',$url_bz2 = '',$url_zip = '',$url_changelog = '',$url_rpm = '',$url_deb = '',$url_osx = '',$url_bsdport = '',$url_purchase = '',$url_cvs = '',$url_list = '',$url_mirror = '',$url_demo = ''){
		$f=new xmlrpcmsg('publish_release', array(
						new xmlrpcval($SID, "string"),
						new xmlrpcval($project_name, "string"),
						new xmlrpcval($branch_name, "string"),
						new xmlrpcval($version, "string"),
						new xmlrpcval($changes, "string"),
						new xmlrpcval($release_focus, "string"),
						new xmlrpcval($hide_from_frontpage, "string"),
						new xmlrpcval($license, "string"),
						new xmlrpcval($url_homepage, "string"),
						new xmlrpcval($url_tgz, "string"),
						new xmlrpcval($url_bz2, "string"),
						new xmlrpcval($url_zip, "string"),
						new xmlrpcval($url_changelog, "string"),
						new xmlrpcval($url_rpm, "string"),
						new xmlrpcval($url_deb, "string"),
						new xmlrpcval($url_osx, "string"),
						new xmlrpcval($url_bsdport, "string"),
						new xmlrpcval($url_purchase, "string"),
						new xmlrpcval($url_cvs, "string"),
						new xmlrpcval($url_list, "string"),
						new xmlrpcval($url_mirror, "string"),
						new xmlrpcval($url_demo, "string")
						));
		return freshmeat::q($f);
	}

	/**
	 * Take back a release submission
	 * 
	 * @param string $SID	Session ID
	 * @param string $project_name	Project name
	 * @param string $branch_name	Branch name
	 * @param string $version	Release version string
	 * @return 
	 **/
	function withdraw_release($SID,$project_name,$branch_name,$version){
		$f=new xmlrpcmsg('withdraw_release', array(new xmlrpcval($SID, "string"),new xmlrpcval($project_name, "string"),new xmlrpcval($branch_name, "string"),new xmlrpcval($version, "string")));
		return freshmeat::q($f);
	}
	
	/**
	 * Query the XML-RPC server and return result
	 * @param 
	 * @access public
	 * @return void 
	 **/
	function q($f){
		$c=new xmlrpc_client("/xmlrpc", "freshmeat.net", 80);
		
		$r=$c->send($f);
		
		$v=$r->value();
		
		if (!$r->faultCode()) {
		
			$res = $v->scalarval();
			
			return $res;
		} else {
			$err =  "Fault: ";
			$err .= "Code: " . $r->faultCode() . 
			" Reason '" .$r->faultString()."'<BR>";
			return $err;
		}
	}
	
	
}


print_r(freshmeat::fetch_branch_list('','paypalshoppingcart'));

?>
Return current item: Freshmeat.net XML-RPC