草庐IT

stream-operators

全部标签

php - 如何检测 stream_copy_to_stream 错误?

我有一些代码,简化后看起来像这样:$fout=fsockopen($host,80);stream_set_timeout($fout,10*3600);//10hours$fin=fopen($file,'rb');//notreallyafilestream,butgoodenoughproxyhere$readbytes=stream_copy_to_stream($fin,$fout);if(!$readbytes)die('copyfailed');但是,我有时会遇到以下类型的错误:Notice:stream_copy_to_stream():sendof952bytesfa

php - 正则表达式帮助 : how to match only either pattern in a regex that contains "or" operator?

我正在使用php的preg_replace().基本上我有2种可能的字符串匹配:你好现实世界问候这是我希望完成的:HelloRealWorldGreetings规则解释:如果字符串包含空格,插入在第一个空格字符之后。如果字符串不包含空格(一个单词),则插入就在字符串的中间(+/-如果奇数字符计数)。到目前为止,我已经想出了一个长期有效的解决方案:",$str,1):preg_replace("/.{".round(strlen($str)/2)."}/","$0",$str,1);?>但是,我相信它可以通过一个更短、更优雅的正则表达式来完成,只有一个preg_replace()。打电话

php - GAE、PHP 和 GCM : failed to open stream: HTTP request failed! HTTP/1.0 405 方法不允许

我正在开发一个Web应用程序(使用适用于PHP的GAE),它会在某些内容可供下载时通知Android客户端(通过GCM-GoogleCloudMessaging)。下面的PHP脚本应该可以完成工作:$json=array('data'=>array(...),'registration_ids'=>array(...));$data=json_encode($json);$context=array('http'=>array('method'=>'post','header'=>'Authorization:key=MY_SECRET_KEY'."\r\n".'Content-Typ

php - curl 错误 28 : Operation timed out after 2000 milliseconds with 7276200 out of 23000995 bytes received

描述我在Laravel项目中使用Guzzle。当我向返回大量有效负载的API发出请求时,我遇到了内存崩溃。我在CURL.php类的顶部有这个。我有使用Guzzle的get()。useGuzzleHttp\Exception\GuzzleException;useGuzzleHttp\Client;useGuzzleHttp\FORCE_IP_RESOLVE;useGuzzleHttp\DECODE_CONTENT;useGuzzleHttp\CONNECT_TIMEOUT;useGuzzleHttp\READ_TIMEOUT;useGuzzleHttp\TIMEOUT;classCUR

php - 如何获得 facebook 应用程序的 publish_stream 权限?

我有一个已经运行了一段时间的应用程序,它只请求了一些用于登录目的的帐户信息。现在我想用它来发布到流。我已将publish_stream添加到req_perms,但它仍然没有请求该权限。我错过了什么吗?FACEBOOKAPPID,'secret'=>FACEBOOKSECRET,'cookie'=>false,));$fb_session=$facebook->getUser();$fb_me=null;//SessionbasedAPIcall.if($fb_session){try{$fb_uid=$fb_session;$fb_me=$facebook->api('/me');$f

php - 验证码 file_get_contents() : SSL operation failed

我正在为我的网页使用GooglereCaptcha。在测试模式下一切正常。无SSL。当我在生产环境中测试我的网页时,出现以下错误:Warning:file_get_contents():SSLoperationfailedwithcode1.OpenSSLErrormessages:error:14090086:SSLroutines:SSL3_GET_SERVER_CERTIFICATE:certificateverifyfailedin/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.phponline68Warni

PHP 警告 : require_once(/var/www/html/wp-config. php) : failed to open stream: Permission denied in/var/www/html/wp-load. php on line 37

我正在apache上创建一个Wordpress应用程序服务器,在访问url时收到错误500。因此,我确实检查了httpd/logs/error_log,以下是错误[SunJan1522:42:54.4403492017][:error][pid767][client10.203.116.148:9173]PHPWarning:require_once(/var/www/html/wp-config.php):failedtoopenstream:Permissiondeniedin/var/www/html/wp-load.phponline37[SunJan1522:42:54.44

php - file_put_contents(.../bootstrap/cache/services.json) : failed to open stream: No such file or directory

我在运行任何phpartisan命令时一直收到此错误。[ErrorException]file_put_contents(/Applications/MAMP/htdocs/code/bheng/md-bheng/bootstrap/cache/services.json):failedtoopenstream:Nosuchfileordirectory我该如何阻止它? 最佳答案 编辑-如果services.json文件不存在,运行phpartisanserve然后停止强制创建文件。请参阅:laravelservices.jsonn

php - 使用 Graph API 通过 PHP 发布到 Facebook Stream

我正在尝试使用新的图形API和PHP将消息发布到用户的墙上。连接似乎工作正常,但没有出现任何帖子。我不确定如何正确设置发布代码。请帮帮我。抱歉,看起来很糟糕的代码,出于某种原因,StackOverflow不想在代码块中将其全部关闭。下面是我的完整代码。我是否缺少扩展程序权限请求,或者是否在这段代码中得到了注意:PHP代码'xxxxxxxxxxxxxxxxxx','secret'=>'xxxxxxxxxxxxxxxxxxxxxxxxxx','cookie'=>true));$session=$facebook->getSession();if(!$session){$url=$faceb

php - stream_socket_client 通过 http 代理

我正在研究APNS(Apple推送通知服务)。我正在按照教程所说的那样做:$ctx=stream_context_create();stream_context_set_option($ctx,'ssl','local_cert','ck.pem');stream_context_set_option($ctx,'ssl','passphrase',$passphrase);$fp=stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195',$err,$errstr,60,STREAM_CLIENT_CONNECT|