国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

已解決:網(wǎng)站部署后可以正常訪問,但是用curl請(qǐng)求時(shí)總是返回false。解決辦法:在服務(wù)器進(jìn)行域名內(nèi)網(wǎng)ip解析。

gongaiorg

問題描述

問題已解決:
是因?yàn)樵浦鳈C(jī)的問題,需要在本地進(jìn)行解析,而且不能用公網(wǎng)ip,要用127.0.0.1
非常感謝大佬的指導(dǎo),解決了這個(gè)困擾大半天的困惑,大佬一語道破,解決問題,非常感謝?。?!

1、部署在linux服務(wù)器上了,并且是兩個(gè)不同站點(diǎn)的網(wǎng)址請(qǐng)求,并非同一個(gè)進(jìn)程

2、用webman框架,網(wǎng)站部署后可以正常訪問 https://push.21c.xin/ ,但是用curl請(qǐng)求網(wǎng)站時(shí)總是返回false,

3、同樣的代碼,更換請(qǐng)求其它網(wǎng)址可以正常返回值,這是服務(wù)器的配置問題嗎?怎么修改呢,找了很多方案都不行,特請(qǐng)教大佬!

測(cè)試網(wǎng)址:https://sso.21c.xin/passport/index/curl?url=https://baidu.com 可以正常返回百度的首頁內(nèi)容
var_dump($tmpInfo); 返回html源碼
var_dump(curl_errno($curl)); 返回0
var_dump(curl_getinfo($curl, CURLINFO_HTTP_CODE)); 返回200

curl訪問 網(wǎng)址 https://sso.21c.xin/passport/index/curl?url=https://push.21c.xin/ 卻返回為false
var_dump($tmpInfo); 返回false
var_dump(curl_errno($curl)); 返回52
var_dump(curl_getinfo($curl, CURLINFO_HTTP_CODE)); 返回0

    public function curl(  ): Response
    { 
        $curl = new Curl(); 
        $url =request()->get('url','https://sso.21c.xin');
        $result = $curl->get($url); 
        var_dump($result);
        return json($result);
    } 

3481 4 0
4個(gè)回答

不敗少龍

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'X-AjaxPro-Method:ShowList',
        'Content-Type: application/json; charset=utf-8',
        'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$data = curl_exec($ch);
curl_close($ch);
return json_decode($data, true);
  • gongaiorg 2023-04-23

    我寫的get請(qǐng)求,請(qǐng)求其它網(wǎng)站都可以正常返回,但是請(qǐng)求webman部署的網(wǎng)站不行,都是返回false

  • 不敗少龍 2023-04-23
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
  • gongaiorg 2023-04-23

    https://sso.21c.xin/passport/index/curl1?url=https://baidu.com 用你代碼寫了這個(gè)是正??梢栽L問的
    但是https://sso.21c.xin/passport/index/curl1?url=https://push.21c.xin/ 還是返回false

    應(yīng)該是服務(wù)器設(shè)置的問題嗎

  • 不敗少龍 2023-04-23

    是不是對(duì)方的網(wǎng)站請(qǐng)求頭需要設(shè)置什么的

  • gongaiorg 2023-04-23

    請(qǐng)求的是我自己的服務(wù)器,現(xiàn)在做微服務(wù)架構(gòu),把模塊分離了,不知道服務(wù)器要怎么設(shè)置才能解決這個(gè)問題呢

  • 不敗少龍 2023-04-23

    http_get('https://push.21c.xin/') 我這直接請(qǐng)求你的這個(gè) 可以獲取到值啊

  • gongaiorg 2023-04-23

    你怎么寫的代碼啊
    public function curl1( )
    {
    $url = input('url')?:'https://sso.21c.xin';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = curl_exec($ch);
    curl_close($ch);
    var_dump($result);
    return json($result);
    }
    剛按照你發(fā)的代碼也是不可以呢,返回依然是false

  • 不敗少龍