function.file-get-contents无法打开流:http请求失败

时间:2013-12-04 06:25:18

标签: php

我有一个从URL获取内容的php文件,我收到失败消息'警告:file_get_contents(http://cc.frifon.net/_dosmssend)[function.file-get-contents]:无法打开流:HTTP请求失败!在第24行的C:\ xampp \ htdocs \ SMS \ cuba.php中找不到HTTP / 1.1 404 布尔(假)'

这是我的代码:

        <?php

            $url = 'http://cc.frifon.net/_dosmssend';
            $data = array('sip' => '60146600472', 'uuid' => 
           '503AEE00-FB59-4868-B293-0FA4FFC17ACB', 'pwd' => '233443959918', 
           'key' => 'key', 'to' => 'to', 'message' => 'message' );

           // use key 'http' even if you send the request to https://...
           $options = array(
           'http' => array(
           'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
           'method'  => 'POST',
           'content' => http_build_query($data),
           ),
           );
           $context  = stream_context_create($options);
           $result = file_get_contents($url, false, $context);

           var_dump($result);

           ?>

1 个答案:

答案 0 :(得分:0)

这是因为您提供了一个不存在的网址

http://cc.frifon.net/_dosmssend

返回 404