我正在尝试向salesforce“api”发出一个请求。 但它仅接受其中明确设置为"application/x-www-form-urlencoded"
php curl标题集目前
当我做这个内容类型:
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://www.salesforce.com/servlet/servlet.WebToLead',
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 3,
CURLOPT_POSTFIELDS => json_encode(array (
'first_name' => 'foo',
'last_name' => 'faa',
'email' => '[email protected]',
'oid' => '#hash',
'recordType' => '#hash'
)),
CURLOPT_HTTPHEADER=>array(
'Content-type: application/x-www-form-urlencoded'
)
));
$data = curl_exec($ch);
$info = curl_getinfo($ch);
的响应头内容类型始终是: "text/html;charset=UTF-8"
我发送邮件使用相同的参数邮递员(带正确的标题)实际上有效。
所以问题是你没有从salesforce api使用上面的代码得到任何回应?你是否收到错误回应?您能否提供您正在使用的salesforce文档的链接? – thohl 2014-09-30 12:41:09
nope。这是一个可怕的API,没有提供任何反馈。我知道我的请求是否成功地转到salesforce - >线索,并检查是否实际创建了线索。我很确定问题在于Content-type头。通过邮递员,我可以成功发布到salesforce。当我改变邮递员的内容类型时,它也失败了。 – 2014-09-30 12:51:53