我通过链接将数据传递到我的CRM:
http://www.crmtool.net/lp_NewLead.asp?lp_CompanyID=12345&lp_Username=test&lp_Password=test&lp_SourceType=WEBBusinessTelecom&lp_UserField6=WebForm-AIIMS&lp_Company=Qwerty2&lp_ContactFirstName=Roland&lp_Phone=11111&lp_Email=test
但是当我尝试通过PHP cUrl执行此操作时,它不会发送到CRM:
<?php
$data = array(
"lp_SourceType" => "WEB - Business Telecom",
"lp_UserField6" => "Web Form - AIIMS",
"lp_UserField6" => "Web Form - AIIMS",
"lp_Company" => $business,
"lp_ContactFirstName" => $name,
"lp_Phone" => $phone,
"lp_Email" => $email,
);
$data_string = json_encode($data);
$ch = curl_init('http://www.crmtool.net/lp_NewLead.asp?lp_CompanyID=12345&lp_Username=test&lp_Password=test');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
如何在这种情况下通过cUrlin传递数据?
答案 0 :(得分:0)
给定的URL似乎是GET方法。 您是否尝试将其更改回GET方法并将所有数据阵列放回URL?
答案 1 :(得分:0)
试试这段代码:
<?php
// http://www.crmtool.net/lp_NewLead.asp?lp_CompanyID=12345&lp_Username=test&lp_Password=test&lp_SourceType=WEBBusinessTelecom&lp_UserField6=WebForm-AIIMS&lp_Company=Qwerty2&lp_ContactFirstName=Roland&lp_Phone=11111&lp_Email=test
$data = array(
'lp_CompanyID' => '12345',
'lp_Username' => 'test',
'lp_Password' => 'test',
'lp_SourceType' => 'WEBBusinessTelecom',
'lp_UserField6' => 'WebForm-AIIMS',
'lp_Company' => 'Qwerty2',
'lp_ContactFirstName' => 'Roland',
'lp_Phone' => '11111',
'lp_Email' => 'test',
);
$url = 'http://www.crmtool.net/lp_NewLead.asp?' . http_build_query($data);
$curl = curl_init($url);
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $ch,
));
$resp = curl_exec($curl);
curl_close($curl);
正如您所说,您可以通过链接传递数据。因此,您的CRM通过GET参数接受数据,而不是通过json-request。