1

上次我遇到问题时,这个网站帮了我很多忙。我想知道为什么这个 php 代码不起作用。任何帮助,将不胜感激。我正在尝试使用 ZenDesk 发出自定义用户创建请求。

我得到了工作请求,但是当我编辑代码以使其适合我的 CRM 的实际实例时,它甚至没有尝试发出 PHP 请求。如果代码正确,我验证这应该是可能的。我只是想不通为什么它不正确。

<?php

include("config.php");




$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://url/api/v2/users.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"user\": {\"name\": \"$name\", 
\"email\": \"$email\", \"phone\": \"$phone"}}");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "email" . ":" . "password");

$phone = phone;
$email = email;
$name = name;
$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}

if ( !isset ($_POST['Name']) ||
    !isset ($_POST['Name'] ||
    !isset ($_POST['phone']
            )
            {

            }
curl_close ($ch);

?>

<!DOCTYPE html>
<html>
<body>

<form 
action="://url/agent/users/{{user.id}}/requested_tickets">
First name:<br>
<input type="text" name="name" value="name">
<br>
Last name:<br>
<input type="text" name="email" value="email">
<br><br>
<input type="text" name="phone" value="+15555555555">
 <br><br>    
 <input type="submit" value="Submit">
</form> 

<p>If you click the "Submit" button, the form-data will be sent to a 
page 
called "/action_page.php".</p>

</body>
</html>
4

0 回答 0