<?php
if(isset($_REQUEST['body']))
{
$body = $_REQUEST['body'];
$api_key = "tHx7zm7eb7z3yKHtNb";
$password = "x";
$yourdomain = "appicmobile";
$ticket_data = json_encode(array(
"body" => $body
));
$url = "https://$yourdomain.freshdesk.com/api/v2/tickets/32/reply";
$ch = curl_init($url);
$header[] = "Content-type: application/json";
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$api_key:$password");
curl_setopt($ch, CURLOPT_POSTFIELDS, $ticket_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
$info = curl_getinfo($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($server_output, 0, $header_size);
$response = substr($server_output, $header_size);
if($info['http_code'] == 201)
{
// "Ticket created successfully, the response is given below \n";
//echo "Response Headers are \n";
//echo $headers."\n";
//echo "Response Body \n";
echo "$response";
}
else
{
if($info['http_code'] == 404)
{
echo "Error, Please check the end point \n";
}
else
{
echo "Error, HTTP Status Code : " . $info['http_code'] . "\n";
echo "Headers are ".$headers;
echo "Response are ".$response;
}
}
curl_close($ch);
}
else {
echo "error";
}
?>
虽然通过Android使用php输入数据显示为空。我正在使用排球传递数据。 我试图将数据从Android传递到我的PHP应用程序,但似乎POST方法运行不正常,一旦所有$ _REQUEST变量都为空。 尝试了所有方法获取,发布但仍无法正常工作