PHP:如何将xml参数发布到api?

I have to post to url : https://rightsignature.com/api/templates.xml

One of the arguments is merge_fields and the description is:

Specify the name and email of the roles returned from the prepackageTemplate call. Roles can be references by or by in the form of XML node attributes 'merge_field_name' or 'merge_field_id'. If specified by name (the easiest method), all merge fields with the name specified will take on the value specified. Optional node specifying whether to "lock" the value from the sender is availbed via .

This is what the post xml should look look like:

        <merge_fields>
          <merge_field merge_field_id="a_233_f309f82jklnm_232">
            <value>$100 per hour</value>
           <locked>true</locked>
          </merge_field>
          <merge_field merge_field_name="Employee Name">
            <value>J. Employee</value>
          </merge_field>
        </merge_fields>

This is what xml response looks like:

            <merge-fields>
              <merge-field>
                <page>1</page>
                <name>Company Name</name>
                <id>a_966_8bffa095998e41ecbdfb624b2fd_5671</id>
             </merge-field>
             </merge-fields>

Am I suppose to set it to an array like this? :

   $arr= array('merge_fields'=>
        array('merge_field_email'=>xxx@mail.com),
       "another_field"=>"another_value")
    )

https://rightsignature.com/api/templates.xml? . $arr

"Well, basically 'it's still AJAX,'" with the encoding being XML not JSON.

You would simply use appropriate XML-manipulation primitives to build and un-build your messages, as discussed here: http://php.net/manual/en/book.xml.php.

It is also possible that the API is what's called SOAP. as discussed here: http://php.net/manual/en/book.soap.php. Or, it might be XML-RPC ("XML remote procedure calls"), as discussed here: http://php.net/manual/en/book.xmlrpc.php.

All three of these pages refer to many other pages with related topics that will be highly-relevant to what you are now trying to do.

It's important that you carefully identify the exact "flavor" of API that you are dealing with, so as to use the most-powerful available libraries of existing code to deal with it at the highest possible level of abstraction. Also, do on-line research (e.g. at GitHub) to see if you can find any existing source-code that already references this API or something very-similar to it. ("Do not do a thing already done.")

The good news is, you know that you're embarking upon "a very, very familiar task" that is well-supported in PHP. And so, to borrow a Perl by-line: "there's more than one way to do it." Search for the most efficient way.