Curl 如何使用Zoho CRM v2 API添加Zoho CRM销售线索
如何使用简单的curl连接,通过Zoho CRM v2 API添加Zoho CRM Lead?文档不仅不清楚如何添加潜在客户,而且不清楚如何获得适当的oAuth令牌来创建潜在客户。对此过程不太清楚。所以,我将简化这个。最大的障碍是获取刷新令牌的步骤。一旦有了这些,您就可以生成无数用于进行实际API调用的访问令牌 如何获取刷新令牌Curl 如何使用Zoho CRM v2 API添加Zoho CRM销售线索,curl,oauth-2.0,crm,zoho,lead,Curl,Oauth 2.0,Crm,Zoho,Lead,如何使用简单的curl连接,通过Zoho CRM v2 API添加Zoho CRM Lead?文档不仅不清楚如何添加潜在客户,而且不清楚如何获得适当的oAuth令牌来创建潜在客户。对此过程不太清楚。所以,我将简化这个。最大的障碍是获取刷新令牌的步骤。一旦有了这些,您就可以生成无数用于进行实际API调用的访问令牌 如何获取刷新令牌 使用管理员级别的帐户登录Zoho CRM,并在选项卡中打开该帐户。然后,在另一个浏览器选项卡中,登录到Developer API控制台: 在开发人员API控制台中,您需
https://accounts.zoho.com/oauth/v2/auth?
因此,您将拥有类似于:grant_type: authorization_code
code: {the code you recorded from step 7}
client_id: {the Client ID you recorded in step 3}
client_secret: {the Client Secret you recorded in step 3}
redirect_uri: {the Authorized Redirect URI you recorded in step 2}
grant_type: refresh_token
refresh_token: {use the refresh_token (the one I said that would last forever) from your stored config file from step 10 in the previous steps}
client_id: {use your client_id}
client_secret: {use your client_secret}
curl "https://accounts.zoho.com/oauth/v2/token" \
-X POST \
-d "grant_type=authorization_code&code=1000.aaa1f9aa8582eaaaafeaddfaf0f3b6b.bf7fe646ba899783501c21a9a3240aaa&client_id=1000.AAAA0BSIC7C9AAAARILR3MGXBYAC8AAA&client_secret=aaa9aa9166055932ff8c0279c6253a65cb534daaaa&redirect_uri=https%3A%2F%2Fexample.com%2Fzohoconfirm"
grant_type: authorization_code
code: {the code you recorded from step 7}
client_id: {the Client ID you recorded in step 3}
client_secret: {the Client Secret you recorded in step 3}
redirect_uri: {the Authorized Redirect URI you recorded in step 2}
{"access_token":"1000.aaaa5579abeea73871b096c941ec1df8.7835dbb43bbf5122f2d5810f0b65aaa","refresh_token":"1000.aaaa2683a1723d1aeb7b58899849aaaa.aaaa4c22481da67e85e598f4b988aaa","api_domain":"https://www.zohoapis.com","token_type":"Bearer","expires_in":3600}
curl "https://accounts.zoho.com/oauth/v2/token" \
-X POST \
-d "grant_type=refresh_token&refresh_token=1000.aaaa2683a1723d1aeb7b58899849aaaa.aaaa4c22481da67e85e598f4b988aaa&client_id=1000.AAAA0BSIC7C9AAAARILR3MGXBYAC8AAA&client_secret=aaa9aa9166055932ff8c0279c6253a65cb534daaaa"
grant_type: refresh_token
refresh_token: {use the refresh_token (the one I said that would last forever) from your stored config file from step 10 in the previous steps}
client_id: {use your client_id}
client_secret: {use your client_secret}
{"access_token":"1000.aaa1c95788b34226c2844a841bfd1d5.6aff70f4adbc3fee9e6b57579e481aaa","api_domain":"https://www.zohoapis.com","token_type":"Bearer","expires_in":3600}
Authorization: Zoho-oauthtoken XXXXXX
<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
header('Content-Type: text/plain');
$sAccessToken = '1000.aaaa5579abeea73871b096c941ec1df8.7835daaa3bbf5122f2d5810f0b65aaaa'; // change me
$sJSON = json_encode(array(
'First_Name' => 'Mickey',
'Last_Name' => 'Mouse',
'Email' => 'mickey@example.com',
'Phone' => '444-444-4444',
'Lead_Source' => 'TEST1'
));
$sJSON = str_replace('{','[{',$sJSON);
$sJSON = str_replace('}','}]',$sJSON);
$sJSON = '{"data":' . $sJSON . '}';
echo "SENDING: $sJSON\n";
$sURL = 'https://www.zohoapis.com/crm/v2/Leads';
$sResponse = @ file_get_contents($sURL,false,stream_context_create(array('http'=>array(
'ignore_errors' => TRUE, // critical if you want to see errors in response instead of empty on error
'method' => 'POST',
'header' => array(
'Content-Type: application/json',
"Authorization: Zoho-oauthtoken $sAccessToken",
'cache-control: no-cache'
),
'content' => $sJSON
))));
echo "$sResponse\n";
{"data":[{"code":"SUCCESS","details":{"Modified_Time":"2020-05-21T20:45:24-04:00","Modified_By":{"name":"John Manager","id":"9999889000000279991"},"Created_Time":"2020-05-21T20:45:24-04:00","id":"9999889000000279991","Created_By":{"name":"John Manager","id":"9999889000000279991"}},"message":"record added","status":"success"}]}