国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

首頁 後端開發(fā) php教程 PHP獲取遠道文件

PHP獲取遠道文件

Jun 13, 2016 pm 01:24 PM
file get quot the

PHP獲取遠程文件
if(!($contents=file_get_contents('http://finance.yahoo.com/d/quotes.csv?s=AMZN&e=.csv&f=slldltlclohgv'))){
die('fail to open yahoo');
};
echo $contents;


為什么平均要刷新3-4下才有一次成功,其他都會出現(xiàn)一個警告,提示 HTTP request failed!


------解決方案--------------------

C/C++ code
Bart Friederichs 16-Apr-2012 12:17
file_get_contents can do a POST, create a context for that first:

$opts = array('http' =>
  array(
    'method'  => 'POST',
    'header'  => "Content-Type: text/xml\r\n".
      "Authorization: Basic ".base64_encode("$https_user:$https_password")."\r\n",
    'content' => $body,
    'timeout' => 60
  )
);
                        
$context  = stream_context_create($opts);
$url = 'https://'.$https_server;
$result = file_get_contents($url, false, $context, -1, 40000);
pperegrina 21-Dec-2011 11:30
For those having this problem when trying to get_file_contents(url):

Warning: file_get_contents(url): failed to open stream: HTTP request failed!  in xx on line yy

If you are behind a SonicWall firewall, read this:
https://bugs.php.net/bug.php?id=40197
(this little line: uncheck a box in the internal settings of the firewall labled "Enforce Host Tag Search with for CFS")

Apparently by default SonicWall blocks any HTTP request without a "Host:" header, which is the case in the PHP get_file_contents(url) implementation.

This is why, if you try to get the same URL from the same machine with cURL our wget, it works.

I hope this will be useful to someone, it took me hours to find out :)
godwraith01 at yahoo dot com 11-Oct-2011 04:16
I experienced a problem in using hostnames instead straight IP with some server destinations.

If i use file_get_contents("www.jbossServer.example/app1",...)
i will get an 'Invalid hostname' from the server i'm calling.

This is because file_get_contents probably will rewrite your request after getting the IP, obtaining the same thing as :
file_get_contents("xxx.yyy.www.zzz/app1",...)

And you know that many servers will deny you access if you go through IP addressing in the request.

With cURL this problem doesn't exists. It resolves the hostname leaving the request as you set it, so the server is not rude in response. <div class="clear">
                 
              
              
        
            </div>
本網(wǎng)站聲明
本文內(nèi)容由網(wǎng)友自願投稿,版權(quán)歸原作者所有。本站不承擔(dān)相應(yīng)的法律責(zé)任。如發(fā)現(xiàn)涉嫌抄襲或侵權(quán)的內(nèi)容,請聯(lián)絡(luò)admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅(qū)動的應(yīng)用程序,用於創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

php blob怎麼轉(zhuǎn)file php blob怎麼轉(zhuǎn)file Mar 16, 2023 am 10:47 AM

php blob轉(zhuǎn)file的方法:1.建立一個php範(fàn)例檔;2、透過「function blobToFile(blob) {return new File([blob], 'screenshot.png', { type: 'image/jpeg' })} 」方法實作Blob轉(zhuǎn)File即可。

使用java的File.length()函數(shù)取得檔案的大小 使用java的File.length()函數(shù)取得檔案的大小 Jul 24, 2023 am 08:36 AM

使用Java的File.length()函數(shù)取得檔案的大小檔案大小是在處理檔案作業(yè)時很常見的一個需求,Java提供了一個很方便的方法來取得檔案的大小,即使用File類別的length()方法。本文將介紹如何使用此方法來取得檔案的大小,並給出對應(yīng)的程式碼範(fàn)例。首先,我們需要建立一個File物件來表示我們想要取得大小的檔案。以下是建立File物件的方法:Filef

鴻蒙原生應(yīng)用隨機詩詞 鴻蒙原生應(yīng)用隨機詩詞 Feb 19, 2024 pm 01:36 PM

想了解更多關(guān)於開源的內(nèi)容,請造訪:51CTO鴻蒙開發(fā)者社群https://ost.51cto.com運行環(huán)境DAYU200:4.0.10.16SDK:4.0.10.15IDE:4.0.600一、建立應(yīng)用程式點擊File- >newFile->CreateProgect。選擇模版:【OpenHarmony】EmptyAbility:填寫項目名,shici,應(yīng)用包名com.nut.shici,應(yīng)用儲存位置XXX(不要有中文,特殊字符,空格)。 CompileSDK10,Model:Stage。 Device

2 個月不見,人形機器人 Walker S 會摺衣服了 2 個月不見,人形機器人 Walker S 會摺衣服了 Apr 03, 2024 am 08:01 AM

機器之能報道編輯:吳昕國內(nèi)版的人形機器人+大模型組隊,首次完成疊衣服這類複雜柔性材料的操作任務(wù)。隨著融合了OpenAI多模態(tài)大模型的Figure01揭開神秘面紗,國內(nèi)同行的相關(guān)進展一直備受關(guān)注。就在昨天,國內(nèi)"人形機器人第一股"優(yōu)必選發(fā)布了人形機器人WalkerS深入融合百度文心大模型後的首個Demo,展示了一些有趣的新功能?,F(xiàn)在,得到百度文心大模型能力加持的WalkerS是這個樣子的。和Figure01一樣,WalkerS沒有走動,而是站在桌子後面完成一系列任務(wù)。它可以聽從人類的命令,折疊衣物

使用java的File.renameTo()函數(shù)重命名文件 使用java的File.renameTo()函數(shù)重命名文件 Jul 25, 2023 pm 03:45 PM

使用Java的File.renameTo()函數(shù)重命名檔案在Java程式設(shè)計中,我們經(jīng)常需要對檔案進行重命名的操作。 Java提供了File類別來處理檔案操作,其中的renameTo()函數(shù)可以方便地重新命名檔案。本文將介紹如何使用Java的File.renameTo()函數(shù)來重新命名文件,並提供對應(yīng)的程式碼範(fàn)例。 File.renameTo()函數(shù)是File類別的一個方法,

如何使用PowerShell自動執(zhí)行任務(wù) 如何使用PowerShell自動執(zhí)行任務(wù) Feb 20, 2024 pm 01:51 PM

如果您是IT管理員或技術(shù)專家,您一定意識到自動化的重要性。尤其對於Windows用戶來說,MicrosoftPowerShell是最佳的自動化工具之一。微軟為滿足您的自動化需求提供了各種工具,無需安裝第三方應(yīng)用程式。本指南將詳細介紹如何利用PowerShell自動化執(zhí)行任務(wù)。什麼是PowerShell腳本?如果您有使用PowerShell的經(jīng)驗,您可能已經(jīng)使用過命令來設(shè)定您的作業(yè)系統(tǒng)。腳本是.ps1檔案中這些指令的集合。 .ps1檔案包含由PowerShell執(zhí)行的腳本,例如基本的Get-Help

使用java的File.getParent()函數(shù)取得檔案的父路徑 使用java的File.getParent()函數(shù)取得檔案的父路徑 Jul 24, 2023 pm 01:40 PM

使用java的File.getParent()函數(shù)取得檔案的父路徑在Java程式設(shè)計中,我們經(jīng)常需要操作檔案和資料夾。有時候,我們需要取得一個檔案的父路徑,也就是該檔案所在資料夾的路徑。 Java的File類別提供了getParent()方法用來取得檔案或資料夾的父路徑。 File類別是Java對檔案和資料夾的抽象表示,它提供了一系列操作檔案和資料夾的方法。其中,get

java如何發(fā)起http請求呼叫post與get接口 java如何發(fā)起http請求呼叫post與get接口 May 16, 2023 pm 07:53 PM

一、java調(diào)用post介面1、使用URLConnection或HttpURLConnectionjava自帶的,無需下載其他jar包URLConnection方式調(diào)用,如果介面回應(yīng)碼被服務(wù)端修改則無法接收到返回報文,只能當(dāng)回應(yīng)碼正確時才能接收到回傳publicstaticStringsendPost(Stringurl,Stringparam){OutputStreamWriterout=null;BufferedReaderin=null;StringBuilderresult=newSt

See all articles