Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Olle Jonsson http://blog.olle.ter.dk

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Simple XML-RPC in PHP (using cURL)

Ping Technorati using cURL and XMLRPC extensions.

   1  
   2  # Using the XML-RPC extension to format the XML package
   3  $request = xmlrpc_encode_request("weblogUpdates.ping", array("Copenhagen Ruby Brigade", "http://copenhagenrb.dk/") );
   4  
   5  # Using the cURL extension to send it off, 
   6  # first creating a custom header block
   7  $header[] = "Host: rpc.technorati.com";
   8  $header[] = "Content-type: text/xml";
   9  $header[] = "Content-length: ".strlen($request) . "\r\n";
  10  $header[] = $request;
  11  
  12  $ch = curl_init();
  13  curl_setopt( $ch, CURLOPT_URL, "http://rpc.technorati.com/rpc/ping"); # URL to post to
  14  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); # return into a variable
  15  curl_setopt( $ch, CURLOPT_HTTPHEADER, $header ); # custom headers, see above
  16  curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' ); # This POST is special, and uses its specified Content-type
  17  $result = curl_exec( $ch ); # run!
  18  curl_close($ch); 
  19  
  20  echo $result;
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS