草庐IT

content-pages

全部标签

php - file_get_contents 通过 php 失败,通过浏览器工作

我想要实现的目标:获取对API端点的请求,检索XML并随后解析结果。我正在发送一个file_get_contents请求来实现这一点。问题:`file_get_Contents`fails,error:Warning:file_get_contents(https://api.twitter.com/1.1/statuses/mentions_timeline.json):failedtoopenstream:Aconnectionattemptfailedbecausetheconnectedpartydidnotproperlyrespondafteraperiodoftime,o

PHP 多 cURL 性能比顺序 file_get_contents 差

我正在编写一个界面,我必须在其中启动4个http请求才能获取一些信息。我用两种方式实现了接口(interface):使用顺序file_get_contents。使用多curl。我已经用jmeter对2个版本进行了基准测试。结果表明,当jmeter中只有1个线程发出请求时,multicurl比顺序file_get_contents好得多,但当100个线程时更差。问题是:哪些因素会导致multicurl的性能下降?我的multicurl代码如下:$curl_handle_arr=array();$master=curl_multi_init();foreach($call_url_arra

php - 仅限 'POST' 类型的默认特色图片(不包括 'page' )

您好,我正在尝试为post_type='post'设置一个默认特色图片,但不包括post_type='page'。我在子主题的函数文件中编写了以下代码,但我一直收到此错误:Notice:Tryingtogetpropertyofnon-objectin/home/ossettto/public_html/wp-content/themes/sport-child/functions.phponline18functionwpforce_featured(){global$post;$post_type=get_post_type($post->ID);if($post_type==='

php - php 的 file_get_contents 是否忽略文件锁定?

我已经阅读了php的manualpage关于“file_get_contents”函数,它没有说明“file_get_contents”在php文件锁定方面的行为方式。然而,在评论部分,用户Chris建议file_get_contentsdoesnotnormallyrespectPHP'sflocklocking,i.e.advisorylocking.Youcanworkaroundthiswithsomeextracodetorequestasharedlock,like...我测试成功了。我还测试了即使文件已被flock()锁定独家LOCK_EX可以让另一个php进程通过fil

php - 克隆 Laravel 项目并安装 composer 和 npm 然后也给我错误 500 page not found

我创建了项目并将其推送到github现在我把它克隆到另一台电脑上我所做的是>composerinstall>npminstall//alsoimportthesamedatabaseinsql现在,当我在浏览器中打开项目链接时,显示找不到页面的错误500 最佳答案 首先创建复制.env.example到.env文件>copy.env.example.env>phpartisankey:generate然后转到您的.env文件并更改数据库详细信息这可能对你有用 关于php-克隆Larave

php - 消息 : file_get_contents(sso. json):无法打开流:没有这样的文件或目录

我正在尝试手动从JSON文件中获取数据,而不是从URL中获取数据。我使用函数file_get_contents。我得到了错误:Message:file_get_contents(sso.json):failedtoopenstream:Nosuchfileordirectory即使路径是正确的。这是我的结构项目:->kalenderkerja->application->controllers->agendakerjaKalender.phpsso.json->assets->...这是我在user()函数中的代码Kalender.phppublicfunctionuser(){$ur

php - Js Validator Plugin Remote Rules for Unique Value Checking without Refresh Page 在 Ajax 调用后不起作用

我正在尝试使用远程规则验证指定名称。第一次通过输入test值提交表单,提交表单并通过ajax绑定(bind)值。但是在第二次没有刷新页面之后,我尝试通过添加我添加的相同值test来提交表单。我没有收到现有名称的错误消息。这是js代码$("#designationaddedit").validate({rules:{designation_name:{required:true,},designation_copy_name:{remote:{url:base_url+'Designation/designation_name_exists',type:"post",data:{desi

php - 如何检查 file_get_contents 在 PHP 中返回 false 的原因

我试过这样做:$urls=array("https://www.gov.sg/");foreach($urlsas$url){d($url);//$url="http://www.google.com";$data=file_get_contents($url);d($data);}d()是一个类似于var_dump()的第3方函数。我不断收到$data=false。似乎域中的任何页面都在这样做。当我尝试另一个域(如google.com)时,它成功了。页面有效,我在浏览器上试过了。以下类似的帖子提出了URL编码问题,并启用了allow_url_fopen,但这些在此处并不适用:PHPf

php - file_get_contents 和 twitter 的奇怪问题

我制作此功能是为了验证用户的Twitter凭据。它在两个不同的网络服务器上运行。在我的网络服务器上,它运行良好。另一方面,它总是返回1!即使密码是故意错误的。到底是什么导致一台服务器做一件事,而另一台服务器做另一件事? 最佳答案 当我使用用户名/密码的任意组合访问该url时,它总是会返回一些内容,无论是身份验证成功还是失败。file_get_contents()仅在无法打开请求的url时返回FALSE。在我看来,要使您的函数成功,您必须解析返回值以确定身份验证是否成功。 关于php-fi

php - cron file_get_contents() 错误

我有一个使用file_get_contents()的php文件它在浏览器中运行良好,但在作为cron作业运行时失败并出现以下错误:Warning:file_get_contents():URLfile-accessisdisabledintheserverconfigurationin/path/to/the/phpfile.phponline22这是我正在使用的:/usr/bin/php5-q/path/to/the/phpfile.php我已经在php.ini中设置了allow_url_fopen=true但这似乎没有任何效果。不过,一切都在浏览器中完美运行。如何解决?