柳暗花明笔记

    坑人的file_get_contents的stream_context_create的http的method的大小写

    所属分类:[ php&web ] 猫哲学家 发表于:2015-11-16 15:06 浏览:605

    $query = http_build_query($data);

                $opts = array(
                    'http' => array(
                    'method' => 'POST',  // 这个地方一定要大写,如果是小写会报400错误,坑啊
                    'header' => "Content-Type:application/x-www-form-urlencoded\r\n" .
                                "Content-Type:text/json\r\n" .
                                "Content-Length: ".strlen($query)."\r\n".
                                "User-Agent:haha/1.0\r\n",
                                "apiuser:user111\r\n" .
                                "apipass:68edd1dfc8e2fa9026659b368361f554\r\n",
                    'content' =>  $query,
                    )
                );

                $stream_context = stream_context_create($opts);        


                $r = file_get_contents($url, false, $stream_context);

    标签: php  http 
    上一编文章 mysql在命令行中执行sql语句 下一编文章 php上传文件报错类型排查
    最近文章
    发表评论