请求实体的媒体类型“multipart / form-data”不是 支持此资源。\“,\”ExceptionMessage \“不确定表情符号”否 MediaTypeFormatter可用于读取“SmsQueue”类型的对象 来自媒体类型的内容 “多部分/格式数据” \”,\‘ExceptionType \’不确定 表情符号 “System.Net.Http.UnsupportedMediaTypeException \”,\ “堆栈跟踪\” 不确定 表情符号“at System.Net.Http.HttpContentExtensions.ReadAsAsync [T](HttpContent 内容,类型类型,IEnumerable 1格式化程序,IFormatterLogger formatterLogger,CancellationToken cancellationToken)\ r \ n at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage 请求,类型类型,IEnumerable`1格式化程序,IFormatterLogger formatterLogger,CancellationToken cancellationToken)\“}”
// Prepare you post parameters
$postArray = array(
'APIKey' => AUTH_KEY,
'number' => $mobile,
'text' => $message,
'senderid' => SENDER_ID,
'channel' => $channel,
'DCS' => $DCS,
'flashsms' => $flashsms,
'route' => $route
);
// Init the resource
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postArray
));
// Ignore SSL certificate verification
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// Get response
$curlOutput = curl_exec($ch);
// Print error if any
if (curl_errno($ch)) {
echo 'error:' . curl_error($ch);
}
curl_close($ch);
答案 0 :(得分:0)
CURLOPT_POSTFIELDS => http_build_query($ postArray)不起作用
curl_setopt($ cURLConnection,CURLOPT_POSTFIELDS => http_build_query($ postRequest1));
答案 1 :(得分:0)
将标头中的Content-Type设置为application / x-www-form-urlencoded。 像这样使用:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://url.com",
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => http_build_query(['message' => test]),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));