failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

这篇具有很好参考价值的文章主要介绍了failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

PHP Warning 'yii\base\ErrorException' with message 'file_get_contents(https://img12.360buyimg.com/n5/s1200x800_jfs/t1/69307/10/5911/292411/5d3e610cEce4e6f5a/b69fbf56874af00d.jpg): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

上面问题很多种处理方案;比如使用curl等可以参考其他使用产景

定时任务脚本中存在一个批量遍历去请求图片的接口;特别是脚本中,一定的要兼容好,比如try等文章来源地址https://www.toymoban.com/news/detail-743959.html

 /**
     * Created by XX
     * description: 批量同步支付宝商品文件
     */
    public function actionSyncAlipayGoodsFile()
    {
        set_time_limit(0);
        date_default_timezone_set("PRC");
        $store_list = array_column(Store::find()->where(['is_delete' => 0, 'is_recycle' => 0])->select(['id'])->asArray()->all(), 'id');
        if (empty($store_list)) {
            return;
        }
        //遍历商户
        foreach ($store_list as $store_id) {
            $key = CacheKeyEnum::ALIPAY_GOODS_FILE.$store_id;
            $redis = \Yii::$app->redis;
            $len = $redis->llen($key);
            if(!$len){
                continue;
            }
            $successCount = $errorCount = 0;
            for ($i=1; $i<=$len; $i++) {
                $good = $redis->rpop($key);
                if($good){
                    $good = json_decode($good,true);
                    if($good['cover_pic']){

                        //避免图片不存在导致脚本中断问题
                        if(!@fopen($good['cover_pic'], 'r' )){
                            continue;
                        }
                        $file_content = saveAlipayTempImage(file_get_contents($good['cover_pic']));
                        $config = MpConfig::get($store_id);
                        //避免未知原因实例化失败导致其他商户受影响
                        try {
                            $aop = $config->getClient();
                        } catch (\InvalidArgumentException $ex) {
                            continue;
                        }

                        try {
                            $request = AlipayRequestFactory::create('alipay.merchant.item.file.upload', [
                                'scene'=> 'SYNC_ORDER',
                                'file_content'=> '@'.$file_content
                            ]);
                            $response = $aop->execute($request);
                            $data = $response->getData();
                            if(isset($data['material_id']) && $data['material_id']){
                                \app\models\Goods::updateAll(['material_id'=>$data['material_id'],'material_key'=>$data['material_key'],'material_status'=>1],['id'=>$good['id']]);
                                $successCount+=1;
                                \Yii::$app->redis->incr(CacheKeyEnum::ALIPAY_GOODS_FILE_SUCCESS.$store_id);
                            }else{
                                \app\models\Goods::updateAll(['material_reason'=>$data['sub_msg'],'material_status'=>2],['id'=>$good['id']]);
                                $errorCount+=1;
                                \Yii::$app->redis->incr(CacheKeyEnum::ALIPAY_GOODS_FILE_FAIL.$store_id);
                            }
                        }catch (AlipayException $ex) {
                            $errorCount+=1;
                            \Yii::$app->redis->incr(CacheKeyEnum::ALIPAY_GOODS_FILE_FAIL.$store_id);
                            \Yii::error(['data' => $ex->getMessage()], '支付宝订单中心:商品文件上传失败');
                        }
                    }
                }
            }
            \Yii::$app->redis->del(CacheKeyEnum::ALIPAY_GOODS_FILE.$store_id.'TotalCount');
        }
        echo 'batch sync alipay goods file success'. "\n";
    }

到了这里,关于failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • failed to open stream: No such file or directory问题解决大全

    这篇文章主要为大家详细介绍了failed to open stream: No such file or directory问题解决大全,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,有需要的朋友可以收藏方便以后借鉴。 failed to open stream: No such file or directory是PHP站点经常可能会遇到的问题,361源码做了个总结,希望

    2024年02月09日
    浏览(37)
  • 严重: Failed to initialize connector [Connector[HTTP/1.1-8080]] 端口号冲突

    严重: Failed to initialize connector [Connector[HTTP/1.1-8080]] 原因 :这是由于8080端口被占用导致 解决方法: 1、首先按下键盘win+R ,在其中输入“cmd”并回车。 2、打开后输入“netstat -ano”命令查看所有端口被占用情况,找到被占用端口的PID码。 3、按Crtl + Alt + Del 键打开任务管理器,

    2024年02月13日
    浏览(34)
  • 关于android11,12权限问题Unable to decode stream: open failed: EACCES (Permission denied)

    第一次发博客 这个问题是我在制作一款app时发现的,我本来想在一个textview中加入一个图片 但是总是报错 E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/DCIM/Camera/IMG_20230129_123518.jpg: open failed: EACCES (Permission denied) 我在浏览了大多数关于这个问题的讨论和

    2024年02月07日
    浏览(43)
  • GET http://localhost:8080/xx/xx 404 (Not Found) 和Uncaught (in promise) Error: failed报错的原因

    这两天,我遇见了一个很离谱的错误,我找不到原因发生在哪里,但是知道代理服务器出错了,代理了后端给的接口,但是,却向本地发起请求,快把我整崩溃了 GET http://localhost:8080/xx/xx 404 (Not Found) 和Uncaught (in promise) Error: failed 开启代理后,发起请求,因为后端给的路径没有

    2024年02月07日
    浏览(33)
  • Error: Could not open client transport with JDBC Uri: jdbc:hive2://hadoop102:10000: Failed to open..

    在hive目录下使用beeline命令:  具体的报错信息如下所示: 22/04/10 01:13:24 [main]: WARN jdbc.HiveConnection: Failed to connect to hadoop102:10000 Error: Could not open client transport with JDBC Uri: jdbc:hive2://hadoop102:10000: Failed to open new session: java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException(org.apache.hado

    2024年02月11日
    浏览(52)
  • 前端JQuery引入不成功报错Failed to load resource: the server responded with a status of 404 (Not Found);

    路径没有问题( 采用相对路径 , 两种打开文件夹方式都是看到Jquery,VScode里面,不排除这个存在理解错误) ,但VScode打开文件夹不一样,引入的JQuery放在其他文件夹时,报错 Failed to load resource: the server responded with a status of 404 (Not Found); Refused to execute script from \\\'http://127.0.0.1:55

    2024年02月13日
    浏览(32)
  • Could not proxy request /captchaImage from localhost to http://localhost:8080/.

    项目场景:配置若依环境前端通过 run npm dev 启动报500 根据报错分析,无法将请求,/路径,从本地主机代理到http://本地主机:8080/   我们可以看到前端配置的端口号80 地址就是本机没有问题,排除前端问题 那就是后端配置文件映射路径有问题 原来配置文件端口是8125,改成

    2024年02月16日
    浏览(30)
  • ❤ error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)

    使用Git的时候今天突然遇到了问题 今天突然使用Mac报错: Git遇到一个问题,如标题 1.搜罗一大堆最终指向这是http2本身的bug。 1.(推荐)直接换掉Git的http版本 git config --global http.version HTTP/1.1 2.更改Git的http克隆为ssh,使用ssh进行提交和拉取代码 — 使用ssh连接Git操作指南(…更新

    2024年02月04日
    浏览(40)
  • 爬虫requests使用代理报错Your proxy appears to only use HTTP and not HTTPS...

    python版本:3.9.4 requests版本:2.28.2 详细报错如下 代理使用如下: 使用如下代理设置,报错得到解决 总结:由于之前使用的是python3.6.8版本,代理设置为’https’: \\\'https://xxxx’可以正常使用,而升级到python3.9.4则出现了上述问题。建议代理的使用统一为 ‘https’: ‘http://xxxx’

    2024年02月15日
    浏览(48)
  • unable to access ‘https://github.com/***/‘: HTTP/2 stream 1 was not closed cleanly before end

    错误提示: 错误原因: 当前git的网络协议和github要求的不一致; 解决方法: 执行上面指令后: .gitconfig中添加了http/1.1的协议,再提交试试;

    2024年02月03日
    浏览(32)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包