doupeng5320 2016-08-11 14:40
浏览 29

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
  • 写回答

1条回答 默认 最新

  • dongwu1410 2016-08-11 16:02
    关注

    "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.

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)