简体   繁体   中英

How to input Post Data to xmlrpc.php?

We have xmlrpc.php with one CMS, I am trying to give POST input to xmlrpc.php .

<methodCall>
    <methodName>openads.view</methodName>
    <params>
      <param>
        <value>
            <struct>
                <member>
                    <name>Ronald</name>
                    <value>25</value>
                </member>
        <member>
      </member>
      <member>
        <name>cookies</name>
        <value>
        <array>123123</array>
      </value>
      </member>
      </struct>
      </value>
      </param>
      <param><value><string>height</string></value></param>
      <param><value><int>1</int></value></param>
      <param><value><string>hjbj3h3</string></value></param>
      <param><value><string>kj3n434kjn</string></value></param>
      <param><value><boolean>1</boolean></value></param>
      <param><value><array><data>342</data></array></value></param>
    </params>
    </methodCall>

I am trying to give above XML POST input to the XMLRPC.php , by using PHP but execution getting failed. How i can input all this inputs using php ? If you have any example you can suggest me.

Try to send the xml as POST request with cURL. The data arrives as $_POST['xml']. Read the docs of your xmlrpc.php library, if this is accepted, else adjust it.

    $url = 'http://somewhere/xmlrpc.php';        

    $xmlString = '<methodCall>....'; // your xml

    $post = array(                   // POST
       'xml' => $xmlString; 
    );

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);    // <--- POST array
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $output = curl_exec($ch);

    if(curl_errno($ch)) {
        print curl_error($ch);
    } else {
        curl_close($ch);
    }

    echo $output;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM