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 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等