Error on cURL request using php-cURL while sending SMS

别来无恙 提交于 2019-12-11 12:35:33

问题


The request entity's media type 'multipart/form-data' is not supported for this resource.\",\"ExceptionMessage\"unsure emoticon"No MediaTypeFormatter is available to read an object of type 'SmsQueue' from content with media type 'multipart/form-data'.\",\"ExceptionType\"unsure emoticon"System.Net.Http.UnsupportedMediaTypeException\",\"StackTrace\"unsure emoticon" at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable 1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, 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);

来源:https://stackoverflow.com/questions/37444262/error-on-curl-request-using-php-curl-while-sending-sms

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!