简体   繁体   English

file_get_contents():假设application / x-www-form-urlencoded with imgur API,未指定Content-type

[英]file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded with imgur API

I'm trying to create an app to upload profile images to imgur but I'm having a problem. 我正在尝试创建一个应用程序来上传个人资料图片,但我遇到了问题。

if (isset($_POST['uploadprofileimg'])) {
   $image = base64_encode(file_get_contents($_FILES['profileimg']['tmp_name']));

   $options = array('http' => array(
       'method' => "POST",
       'header' => "Authorization: Bearer sdf541gs6df51gsd1bsb16etb16teg1etr1ge61g\n",
       "Content-Type: application/x-www-form-urlencoded",
       'content' => $image
   ));

   $context = stream_context_create($options);

   $imgurURL = "https://api.imgur.com/3/image";

   $response = file_get_contents($imgurURL, FALSE, $context);
}

I'm getting this notice: 我收到了这个通知:

Notice: file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded in C:\\WebServer\\Apache24\\Apache24\\htdocs\\html\\www\\SocialNetwork\\my-account.php on line 17 注意:file_get_contents():未指定Content-type假设在第17行的C:\\ WebServer \\ Apache24 \\ Apache24 \\ htdocs \\ html \\ www \\ SocialNetwork \\ my-account.php中的application / x-www-form-urlencoded

even though this doesn't break my app, it's annoying. 虽然这不会破坏我的应用程序,但这很烦人。 How can I fix it? 我该如何解决?

I've tried to add "User-Agent:MyAgent/1.0\\r\\n", and "Connection: close" to the header part but it doesn't seem to fix it!!!! 我试图在标题部分添加“User-Agent:MyAgent / 1.0 \\ r \\ n”和“Connection:close”但它似乎没有修复它!

Try replacing the options array with: 尝试将options数组替换为:

$options = array('http' => array(
    'method' => "POST",
    'header' =>
        "Content-Type: application/x-www-form-urlencoded\r\n".
        "Authorization: Bearer sdf541gs6df51gsd1bsb16etb16teg1etr1ge61g\n",
    'content' => $image
));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 file_get_contents():假设应用程序/x-www-form-urlencoded 未指定内容类型 - file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded 重新验证错误; 注意:file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded in - recaptcha error; Notice: file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded in PHP - 假设应用程序/x-www-form-urlencoded 未指定内容类型 - PHP - Content-type not specified assuming application/x-www-form-urlencoded 的file_get_contents( 'PHP://输入'); 与application / x-www-form-urlencoded; - file_get_contents('php://input'); with application/x-www-form-urlencoded; 如何使用内容类型从 webhook 获取数据:application/x-www-form-urlencoded;charset=UTF-8? - How to get data from webhook with content-type: application/x-www-form-urlencoded;charset=UTF-8? 使用Content-Type = application / x-www-form-urlencoded发送POST请求时,POST值为空 - POST value is empty when Sending POST request with Content-Type = application/x-www-form-urlencoded 如何通过在laravel中传递参数来获得内容类型application/x-www-form-urlencoded的响应 - How to get response of content type application/x-www-form-urlencoded by passing parameters in laravel PHP curl将Content-Type更改为application / x-www-form-urlencoded。 不应该这样做 - PHP curl changes the Content-Type to application/x-www-form-urlencoded. Shouldn't do that 如何使用内容类型为“ application / x-www-form-urlencoded”的PHP curl发送原始JSON? - How can I send a raw JSON using PHP curl with the content type “application/x-www-form-urlencoded”? 如何在基于XML的API调用中将标头设置为“ application / x-www-form-urlencoded” - How do I set the headers to “application/x-www-form-urlencoded” on a XML based API Call
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM