【发布时间】:2014-03-18 18:02:57
【问题描述】:
我想使用带有 cURL (PHP) 的 XML RPC api (http://www.zoho.com/creator/help/api/xml-rpc-api/xml-rpc-api-add-records.html) 将记录添加到 zoho creator。 我使用的代码是:
<?php
if(isset($_POST['Submit'] )) {
// if data is posted
$urltopost = "https://creator.zoho.com/api/xml/write";
$xml = '<ZohoCreator>
<applicationlist>
<application name=\'myapp\'>
<formlist>
<form name=\'my form\'>
<add>
<field name=\'fieldName\'>
<value>value</value>
</field>
</add>
</form>
</formlist>
</application>
</applicationlist>
</ZohoCreator>';
$datatopost = array (
'authtoken' => '*******', //my authtoken
'scope' => 'creatorapi',
'XMLString' => $xml ,
'zc_ownername' => '*****'//the owner name
);
// post via curl
$ch = curl_init ($urltopost);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$returndata = curl_exec ($ch);
?>
但这不起作用。有没有人有办法解决吗?谢谢。
【问题讨论】: