phpcurl301跳轉如何處理

本篇內(nèi)容介紹了“php curl301跳轉如何處理”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!

專業(yè)成都網(wǎng)站建設公司,做排名好的好網(wǎng)站,排在同行前面,為您帶來客戶和效益!創(chuàng)新互聯(lián)為您提供成都網(wǎng)站建設,五站合一網(wǎng)站設計制作,服務好的網(wǎng)站設計公司,成都網(wǎng)站制作、網(wǎng)站建設負責任的成都網(wǎng)站制作公司!

php curl 301跳轉的處理方法:1、打開相應的php文件;2、通過添加代碼為“curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);”處理301跳轉即可。

curl 301 處理

我在處理某個接口調(diào)用時發(fā)現(xiàn)postman能正常響應數(shù)據(jù),但是程序運行時卻獲取不到正常數(shù)據(jù)響應.

排查日志發(fā)現(xiàn)代碼里curl時會返回301, 所以會導致接口未能正確獲取到響應數(shù)據(jù).

curl -i http://www.example.com/fetchAvailability\?startDate\=2021-02-08\&endDate\=2021-02-08\&startTime\=00%3A00%3A00\&endTime\=23%3A59%3A59
HTTP/1.1 301 Moved Permanently
Date: Tue, 09 Feb 2021 00:39:19 GMT
OT-RequestId: 74eadfc7-50a1-4610-83ab-4beab3581621
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Set-Cookie: OT-SessionId=b1db19cb-00cf-47be-95ac-33eee1172706; Path=/; Domain=example.com; Expires=Tue, 09-Feb-2021 01:09:19 GMT; Max-Age=1800; Secure; SameSite=None
Set-Cookie: OT-Session-Update-Date=1612831159; Path=/; Domain=example.com; Expires=Tue, 09-Feb-2021 01:09:19 GMT; Max-Age=1800; Secure; SameSite=None
Location: https://www.example.com/FetchAvailability?startDate=2021-02-08&endDate=2021-02-08&startTime=00%3A00%3A00&endTime=23%3A59%3A59
Content-Length: 0

postman 處理了 301 跳轉.

php curl里如果要處理301 跳轉的問題,需要加上 下面這行代碼:

curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);

“php curl301跳轉如何處理”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關的知識可以關注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!

本文標題:phpcurl301跳轉如何處理
當前路徑:http://bm7419.com/article8/igciip.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版Google、建站公司、響應式網(wǎng)站、網(wǎng)站策劃靜態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設