My favorites | Sign in
Project Home Issues
Project Information
Members
Featured
Downloads

Curlx

Curlx is a PHP5 wrapper class for cURL functions.

Examples

  • Simplified GET request (to fetch a web page, similar to file_get_contents())
  • $curlx = new Curlx;
    $web_page = $curlx->fetch('http://example.com/');
  • Simplified POST request
  • $curlx = new Curlx;
    $web_page = $curlx->fetch('http://example.com/', array('username' => 'User', 'password' => 'pa55word'));
  • Site login
  • // Imagine you're using a social networking site on example.com, 
    // and you want your PHP script to log in and update your profile for you.
    $curlx = new Curlx;
    // This file will be used whenever there's cookie data to be stored or sent to the server.
    $curlx->cookie('my_cookie.text');
    
    // Send a POST request containing your username and password to the login page
    $response = $curlx->fetch('http://example.com/login', array('username' => 'User', 'password' => 'pa55word'));
    
    // Randomly pick a mood for your new profile status
    $moods = array('happy', 'sad', 'angry');
    $current_mood = $moods[mt_rand(0, count($moods) - 1)];
    $status = "I am $current_mood today!";
    
    // Do a status update on your example.com profile
    $response = $curlx->fetch('http://example.com/profile', array('status' => $status));

Bugs?

Tell me and I'll fix it! - http://code.google.com/p/curlx/issues/entry

Powered by Google Project Hosting