David Ansermot Web Developer / TYPO3 Integrator

24mai/110

PHP utility class – Url Checker 1.0

Another light utility class to check if your urls are valids.

Simply get an instance of UrlChecker and check each url. If url is valid, the class'll return "200" success code.

Available on my downloads page or directly here

22oct/100

PHP – Remote post on WordPress using cUrl

Here's a code snippet function for remote posting on WordPress blogs I've made for my usage. It use XML-RPC and cUrl to publish on your blog.
Hope it'll help you.

  1. <?php
  2.  
  3. /**
  4. * Remote post on WordPress function
  5. *
  6. * @date 2010-10-22
  7. * @author David Ansermot
  8. * @url http://www.ansermot.ch
  9. *
  10. * @param string $url: Your blog's url
  11. * @param string $login: Your blog's login
  12. * @param string $pass: Your blog's password
  13. * @param string $postTitle: The post's   title
  14. * @param string $postCats: A comma separated list of categories's ids
  15. * @param string $postContent: The post's content
  16. * @return bool
  17. */
  18. function curlRemotePostToWordPress($url, $login, $pass, $postTitle, $postCats, $postContent) {
  19.  
  20.         // Remote post url
  21.         $rpcUrl = rtrim($url, '/').'/xmlrpc.php';
  22.        
  23.         // Categories for the post
  24.         $categories = explode(',', $postCats);
  25.        
  26.         // Post xml
  27.         $xml = '<title>'.$postTitle.'
  28.          <category>'.$categories.'</category>
  29.          < ![CDATA[ '.$postContent.' ]]>';
  30.  
  31.        
  32.         // Build request
  33.         $params = array('', '', $login, $pass, $xml, 1);
  34.         $request = xmlrpc_encode_request('blogger.newPost', $params);
  35.        
  36.         // Send the request
  37.         try {
  38.        
  39.                 $ch = curl_init();
  40.        
  41.                 // cUrl configuration
  42.                 curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
  43.                 curl_setopt($ch, CURLOPT_URL, $rpcUrl);
  44.                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  45.                 curl_setopt($ch, CURLOPT_TIMEOUT, 1);
  46.        
  47.                 // Execution
  48.                 curl_exec($ch);
  49.                 curl_close($ch);
  50.        
  51.                 return true;
  52.        
  53.         } catch (Exception $e) {
  54.        
  55.                 return false;
  56.        
  57.         }
  58. }
  59.  
  60. ?>
24déc/090

WordPress 2.9.1 Beta 1

Unfortunately, the recent 2.9 release triggered a bug in certain versions of PHP’s curl extension.  With these versions of curl, scheduled posts and pingbacks are not processed correctly.  To fix this problem as well as a handful of other, lesser issues, we are quickly releasing 2.9.1, the first maintenance release of the 2.9 line.  Help us get 2.9.1 ready to go by testing 2.9.1 Beta 1.  The easiest way to test Beta 1 is to install the WordPress Beta Tester plugin, elect to get on the point release development track, and then perform an automatic upgrade via the Tools->Upgrade menu.  You can also download the Beta 1 package and install manually.  Fourteen tickets have been fixed in 2.9.1 Beta 1.  Since the curl problem and a couple of other problems are dependent on specific hosting configurations, any and all testing help is greatly appreciated.

Source : wordpress.org

30nov/090

cURL : 10 way to use it

cURL is a PHP extension to communicate easily with other web sites. Libcurl extension will allow you to perform operations that you do not always have to think like submitting forms.

Jean-Baptiste Jung suggests in an article 10 ways to use the cURL extension.
The issues addressed are:

  • Updating Facebook status
  • Getting server's loading speed
  • Connection with mySpace
  • Post something on your WordPress blog
  • Checking url availability
  • Post on Twitter
  • And many more...

Read the article