Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 文件\u get\u内容挂起,但我设置了超时参数_Php_Linux_Https_Wechat - Fatal编程技术网

Php 文件\u get\u内容挂起,但我设置了超时参数

Php 文件\u get\u内容挂起,但我设置了超时参数,php,linux,https,wechat,Php,Linux,Https,Wechat,我发现了一个奇怪的问题。这是我的php问题代码 static function sendImgMsg($openid, $mediaid, $access) {

我发现了一个奇怪的问题。这是我的php问题代码

static function sendImgMsg($openid, $mediaid, $access)                                                                                                                                                   
{                                                                                                                                                                                                        
    $csSelf= <<<EOF                                                                                                                                                                                      
{                                                                                                                                                                                                            
"touser":"$openid",                                                                                                                                                                                      
"msgtype":"image",                                                                                                                                                                                       
"image":                                                                                                                                                                                                 
{                                                                                                                                                                                                        
  "media_id":"$mediaid"                                                                                                                                                                                  
}                                                                                                                                                                                                                                                                                                                                                                                                                 
EOF;                                                                                                                                                                                                         
    $ret = Util::postRaw('https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $access, $csSelf);                                                                                      
    return json_decode($ret, true);                                                                                                                                                                      
}

static function postRaw($url, $data)
{   
    $opts = array (
        'http' => array (
            'method' => 'POST',
            'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . 
            "Content-Length: " . strlen($data) . "\r\n",
            'content' => $data,
            'timeout' => 60
            )   
        );  

    $context = stream_context_create($opts);
    return file_get_contents($url, false, $context);
}   
静态函数sendImgMsg($openid、$mediaid、$access)
{                                                                                                                                                                                                        
$csSelf=“内容类型:应用程序/x-www-form-urlencoded\r\n”。
“内容长度:”.strlen($data)。“\r\n”,
“内容”=>$data,
“超时”=>60
)   
);  
$context=stream\u context\u create($opts);
返回文件获取内容($url,false,$context);
}   
我调用sendImgMsg函数向特定服务器发送post数据。有时叫它会挂。最后,我发现它挂在文件\u get\u contents api中。我将显示有关文件内容的战略图片。

它挂起在读取系统调用中。但是fd是非阻塞的。为什么?任何建议都将不胜感激。

尽量使用“永不回头:”)尽量使用“永不回头:”)