Send me your improvments! There's a lot to be added/improved! :-) Changelog: 2005-01-24: Basic functionality. FindFeeds() and GetFeed() work. 2005-01-25: DeleteFeed() works too. Distributed under the GNU General Public License. */ var $usr ; var $pass ; function auth($usr,$pass) { $this->usr = $usr ; $this->pass = $pass ; } function libCurlPost($url,$data) { foreach($data as $i=>$v) { $postdata.= $i . "=" . urlencode($v) . "&"; } $postdata.="1"; $ch=curl_init(); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$postdata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ; $info = curl_exec($ch); curl_close($ch); return $info; } function libCurlGet($url,$data) { $postdata = "" ; foreach($data as $i=>$v) { $postdata.= $i . "=" . urlencode($v) . "&"; } $postdata.="1"; $ch=curl_init(); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_URL,"$url?$postdata"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ; $info = curl_exec($ch); curl_close($ch); return $info; } function FindFeeds() { $ret = array() ; $params['user'] = $this->usr ; $params['password'] = $this->pass ; $url = "http://api.feedburner.com/management/1.0/FindFeeds" ; $xml_resp = $this->libCurlGet($url,$params) ; $xml = simplexml_load_string($xml_resp) ; if ($xml->err[0]) { $err_code = $xml->err[0]['code'] ; $err_message = $xml->err[0]['msg'] ; $ret[] = array("error"=>$err_code, $msg=>$err_message) ; } else { foreach ($xml->feeds->feed as $feed) { $ret[] = array( 'id'=> (string)$feed['id'], 'uri'=> (string)$feed['uri'], 'title'=> (string)$feed['title'] ) ; } } return $ret ; } function GetFeed($id) { $ret = array() ; $params['user'] = $this->usr ; $params['password'] = $this->pass ; $params['id'] = $id ; $url = "http://api.feedburner.com/management/1.0/GetFeed" ; $xml_resp = $this->libCurlGet($url,$params) ; $xml = simplexml_load_string($xml_resp) ; if ($xml->err[0]) { $err_code = $xml->err[0]['code'] ; $err_message = $xml->err[0]['msg'] ; $ret[] = array("error"=>$err_code, $msg=>$err_message) ; } else { $ret['url'] = (string) $xml->feed->source['url'] ; foreach ($xml->feed->services->service as $service) { $srv = array() ; foreach ($service->param as $param) { $srv[(string)$param['name']] = (string)$param ; } $ret['service'][ (string)$service['class'] ] = $srv ; } } return $ret ; } function AddFeed($feed) { $ret = array() ; $params['user'] = $this->usr ; $params['password'] = $this->pass ; $params['feed'] = $feed ; $url = "http://api.feedburner.com/management/1.0/AddFeed" ; $xml_resp = $this->libCurlPost($url,$params) ; $xml = simplexml_load_string($xml_resp) ; if ($xml->err[0]) { $err_code = $xml->err[0]['code'] ; $err_message = $xml->err[0]['msg'] ; $ret[] = array("error"=>$err_code, $msg=>$err_message) ; } else { $ret['id'] = (string) $xml->feed['id'] ; $ret['uri'] = (string) $xml->feed['uri'] ; $ret['title'] = (string) $xml->feed['title'] ; print_r($xml) ; } return $ret ; } function DeleteFeed($id) { $ret = array() ; $params['user'] = $this->usr ; $params['password'] = $this->pass ; $params['id'] = $id ; $url = "http://api.feedburner.com/management/1.0/DeleteFeed" ; $xml_resp = $this->libCurlPost($url,$params) ; $xml = simplexml_load_string($xml_resp) ; if ($xml->err[0]) { $err_code = $xml->err[0]['code'] ; $err_message = $xml->err[0]['msg'] ; $ret[] = array("error"=>$err_code, $msg=>$err_message) ; } else { // Empty reply = OK } return $ret ; } // End of Class FeedBurner_Mgmt } /* ********************************************************************** Here is a small example of how the above class can be used ********************************************************************** */ // First create a new instance $fb = new FeedBurner_Mgmt() ; /* Set your feedburner.com username and password (Visit http://feedburner.com/ to create an account if you do not have one) */ $fb->auth('yourusername','yourpassword') ; /* Try to burn a new feed. Read http://www.feedburner.com/fb/a/api/management/docs on how the XML must be formated */ $x = $fb->AddFeed(' ') ; echo "AddFeed Returned:
" ;
print_r($x) ;
echo "
" ; /* Now let's list our feeds. If you did not get an error so far, your new feed should be included in the list. */ $myfeeds = $fb->FindFeeds() ; echo "FindFeeds Returned:
" ;
print_r($myfeeds) ;
echo "
" ; /* Use GetFeed to get a feed's details. */ $feed1_id = $myfeeds[0]['id'] ; $feed1_details = $fb->GetFeed($feed1_id) ; echo "GetFeed [$feed1_id] Returned:
" ;
print_r($feed1_details) ;
echo "
" ; /* Delete Feed If you know your feed's ID (it can get it using FindFeeds() above), and you are *SURE* you want to delete it, use the following code $x = $fb->DeleteFeed('feed id #') ; print_r($x) ; */ ?>