WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Access to WordPress 3.5 through XML-RPC API (4 posts)

  1. elhui2
    Member
    Posted 1 year ago #

    Hi:

    This is my first post in this forum :D

    I need access to http://calaveradigital.com/xmlrpc.php, I use php to convert the data with json_encode(array), this is my script:

    //This have a user, password
    require_once 'config.php';
    //IXR_CLIENT
    require_once '../wp-includes/class-IXR.php';
    //this is the call
    $client= new IXR_Client('http://localhost/domain.com/xmlrpc.php');
    
    $args=array('taxonomies'=>'category');
    
    if (!$client->query('wp.getTaxonomies',$args,$user,$pass)){
    
        echo('Un error ha ocurrido durante la consulta:--->>>.' . $client->getErrorCode().":".$client->getErrorMessage());
    
    }
    
    $cats = $client->getResponse();
    
    echo json_encode($cats);

    This response nothing :'(

    If you have a documentation or manual or something i will very happy.

    thanks and have a nice day

  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    We do not host these 'manuals'

  3. elhui2
    Member
    Posted 1 year ago #

    ¬¬ ok sorry for that, my english is very bad! u.u

    'nanual' = tutorial or 'how to' ... xD

  4. elhui2
    Member
    Posted 1 year ago #

    Hi.
    This is the good script to get categories:

    <?php
    require_once '../wp-includes/class-IXR.php';
    
    $url='http://domain.com/xmlrpc.php';
    $usr='USER';
    $pas='PASSWORD';
    
    $client = new IXR_Client($url);
    
    $content= 'category';
    
    $params= array(0,$usr,$pas,$content);
    
    if(!$client->query('wp.getTerms',$params)){
        die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
    }
    
    $respuesta=$client->getResponse();
    
    header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
    header('Access-Control-Max-Age: 86400');
    header('Access-Control-Allow-Credentials: true');
    header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
    header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-type: application/json');
    
    echo json_encode($respuesta);
    
    ?>

    :D

Topic Closed

This topic has been closed to new replies.

About this Topic