SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2003
    Location
    South Florida
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need Help with fatal error, please

    Hi, All!

    I can't seem to find answer searching google and others

    This is the error:
    Fatal error: Call to undefined function: xmlrpc_encode_request() in /home/vids/public_html/includes/class.RevverAPI.php on line 36

    This is line 36:
    $request = xmlrpc_encode_request($method, $args);

    This is the script:
    <?php

    /*
    The RevverAPI class determines which method of packaging xmlrpc requests is to be
    used, prepares and launches the method call and then returns the result as a standard
    PHP variable. It requires curl support and will use the 'XMLRPC for PHP' library if
    the built in XMLRPC functions for PHP are unavailable.

    PHP
    http://www.php.net/

    XMLRPC
    http://www.xmlrpc.com/

    XMLRPC for PHP
    http://www.php.net/xmlrpc
    http://phpxmlrpc.sourceforge.net/
    */

    class RevverAPI {
    function RevverAPI($url) {
    $this->url = $url;
    $this->curl = function_exists('curl_init');
    $this->xmlrpc = !function_exists('xmlrpc_encode_request');
    }

    function callRemote($method) {
    // Curl is required so generate a fault if curl functions cannot be found.
    if (!$this->curl) return array('faultCode' => -1, 'faultString' => 'Curl functions are unavailable.');
    // The first argument will always be the method name while all remaining arguments need
    // to be passed along with the call.
    $args = func_get_args();
    array_shift($args);
    if ($this->xmlrpc) {
    // If php has xmlrpc support use the built in functions.
    $request = xmlrpc_encode_request($method, $args);
    $result = $this->__xmlrpc_call($request);
    $decodedResult = xmlrpc_decode($result);
    } else {
    // If no xmlrpc support is found, use the phpxmlrpc library. This involves containing
    // all variables inside the xmlrpcval class.
    $encapArgs = array();
    foreach ($args as $arg) $encapArgs[] = $this->__phpxmlrpc_encapsulate($arg);
    $msg = new xmlrpcmsg($method, $encapArgs);
    $client = new xmlrpc_client($this->url);
    $client->verifypeer = false;
    $result = $client->send($msg);
    if ($result->errno) {
    $decodedResult = array('faultCode' => $result->errno, 'faultString' => $result->errstr);
    } else {
    $decodedResult = php_xmlrpc_decode($result->value());
    }
    }
    return $decodedResult;
    }

    function __phpxmlrpc_encapsulate($arg) {
    // The class xmlrpcval is defined in the phpxmlrpc library. It requires both the variable
    // and the type. Dates are handled through the API as ISO 8601 string representations.
    if (is_string($arg)) {
    $encapArg = new xmlrpcval($arg, 'string');
    } elseif (is_int($arg)) {
    $encapArg = new xmlrpcval($arg, 'int');
    } elseif (is_bool($arg)) {
    $encapArg = new xmlrpcval($arg, 'boolean');
    } elseif (is_array($arg)) {
    // The API server treats indexed arrays (lists) and associative arrays (dictionaries)
    // differently where in php they are essentially the same. Assuming that having a zero
    // index set indicates an indexed array is not perfect but should suffice for the
    // purpose of the API examples.
    if (isset($arg[0])) {
    $array = array();
    foreach ($arg as $key => $value) {
    $array[] = $this->__phpxmlrpc_encapsulate($value);
    }
    $encapArray = new xmlrpcval();
    $encapArray->addArray($array);
    $encapArg = $encapArray;
    } else {
    $struct = array();
    foreach ($arg as $key => $value) {
    $struct[$key] = $this->__phpxmlrpc_encapsulate($value);
    }
    $encapStruct = new xmlrpcval();
    $encapStruct->addStruct($struct);
    $encapArg = $encapStruct;
    }
    } else {
    $encapArg = new xmlrpcval($arg, 'string');
    }

    return $encapArg;
    }

    function __xmlrpc_call($request) {
    $header[] = "Content-type: text/xml";
    $header[] = "Content-length: ".strlen($request);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $this->url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $request);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

    $data = curl_exec($ch);
    if (curl_errno($ch)) {
    // Curl errors are returned as emulated xmlrpc faults.
    $errorCurl = curl_error($ch);
    curl_close($ch);
    return xmlrpc_encode(array('faultCode' => -1, 'faultString' => 'Curl Error : '.$errorCurl));
    } else {
    curl_close($ch);
    return $data;
    }
    }

    }

    ?>

    THANKS for any help!
    Joe

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe make
    $this->xmlrpc = !function_exists('xmlrpc_encode_request');
    into
    $this->xmlrpc = function_exists('xmlrpc_encode_request');

  3. #3
    SitePoint Member
    Join Date
    Oct 2003
    Location
    South Florida
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, clamcrusher!

    Great I think corrected the issue

    Now, one more please.

    New error:
    Parse error: syntax error, unexpected T_STRING, expecting ')' in /home/video20/public_html/find.php on line 18

    Script
    <?php

    /*
    video.find
    Return the id, title and thumbnail url of the 10 most viewed videos owned by
    longjohn that contain the word parrot in their metadata.
    */

    include('includes/xmlrpc-2.1/lib/xmlrpc.inc');
    include('includes/class.RevverAPI.php');

    $api = new RevverAPI('https://api.staging.revver.com/xml/1.0?login=mylogin&passwd=mypass');

    $query = array('owners' => array('longjohn'), 'search' => array('parrot'));
    $return = array('id', 'title', 'thumbnailUrl');
    $options = array('limit' => 10, 'orderBy' =>');

    $results = $api->callRemote('video.find', $query, $return, $options);

    //remove below after done testing, just included to show you the output
    echo '<pre>';
    var_dump($results);
    echo '</pre>';


    ?>


    THANKS,
    Joe

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you really should get a dedicated php editer with syntax highlighting. it would be obvious where you went wrong.
    PHP Code:
    <?php

    /*
    video.find
    Return the id, title and thumbnail url of the 10 most viewed videos owned by
    longjohn that contain the word parrot in their metadata.
    */

    include('includes/xmlrpc-2.1/lib/xmlrpc.inc');
    include(
    'includes/class.RevverAPI.php');

    $api = new RevverAPI('https://api.staging.revver.com/xml/1.0?login=mylogin&passwd=mypass');

    $query = array('owners' => array('longjohn'), 'search' => array('parrot'));
    $return = array('id''title''thumbnailUrl');
    $options = array('limit' => 10'orderBy' =>');

    $results = $api->callRemote('
    video.find', $query, $return, $options);

    //remove below after done testing, just included to show you the output
    echo '
    <pre>';
    var_dump($results);
    echo '
    </pre>';


    ?>
    see how the highlighting gets all funky near your error?
    $options = array('limit' => 10, 'orderBy' =>'something missing?');


    also, when you post code, use bbcode tags.
    [php]code goed here[/php]

  5. #5
    SitePoint Member
    Join Date
    Oct 2003
    Location
    South Florida
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, clamcrusher!

    Thanks for your help! I will definately look into that editor!

    Joe


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •