file_get_contents: Unable to find the wrapper https did you forget to enable it when you configured

54 篇文章 3 订阅
36 篇文章 2 订阅

file_get_contents(): Unable to find the wrapper "https"- did you forget to enable it when you configured PHP?

转载地址

1.windows下的PHP,只需要到php.ini中把extension=php_openssl.dll前面的;删掉,重启服务就可以了。 
2.linux下的PHP,就必须安装openssl模块,安装好了以后就可以访问了。 
3.如果服务器你不能修改配置的话,那么就使用curl函数来替代file_get_contents函数,当然不是简单的替换啊。还有相应的参数配置才能正常使用curl函数。 
对curl函数封装如下:

php] view plain copy print?
function http_request($url,$timeout=30,$header=array()){  
        if (!function_exists('curl_init')) {  
            throw new Exception('server not install curl');  
        }  
        $ch = curl_init();  
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
        curl_setopt($ch, CURLOPT_HEADER, true);  
        curl_setopt($ch, CURLOPT_URL, $url);  
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);  
        if (!empty($header)) {  
            curl_setopt($ch, CURLOPT_HTTPHEADER, $header);  
        }  
        $data = curl_exec($ch);  
        list($header, $data) = explode("\r\n\r\n", $data);  
        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);  
        if ($http_code == 301 || $http_code == 302) {  
            $matches = array();  
            preg_match('/Location:(.*?)\n/', $header, $matches);  
            $url = trim(array_pop($matches));  
            curl_setopt($ch, CURLOPT_URL, $url);  
            curl_setopt($ch, CURLOPT_HEADER, false);  
            $data = curl_exec($ch);  
        }  

        if ($data == false) {  
            curl_close($ch);  
        }  
        @curl_close($ch);  
        return $data;  
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当使用Android Studio打包APK文件时出现"unable to find valid certification path to requested target"错误,可能是由于证书路径无效导致的。这个错误通常发生在使用HTTPS连接时,Android Studio无法验证SSL证书。 解决这个问题的方法有几种: 1. 首先,确保你的Android Studio和Java Development Kit (JDK)都是最新版本。有时候这个错误是由于旧版本的软件导致的。 2. 检查你的网络连接是否正常,并确保你可以访问到所需的证书。有时候这个错误是由于网络问题导致的,无法下载或验证证书。 3. 如果你使用的是公司网络,可能需要配置代理服务器。你可以在Android Studio的设置中找到"HTTP Proxy"选项,并进行相应的配置。 4. 可以尝试更改Gradle的版本。在项目的根目录下的`gradle/wrapper/gradle-wrapper.properties`文件中修改`distributionUrl`的值,将Gradle版本更改为较新的版本。然后重新构建项目,看是否能够解决问题。 5. 如果以上方法都不起作用,可以尝试手动导入证书。具体操作可以参考中提到的方法,根据你的情况进行相关设置。 综上所述,如果在使用Android Studio打包APK时遇到"unable to find valid certification path to requested target"错误,可以尝试更新软件版本、检查网络连接、配置代理服务器、更改Gradle版本或者手动导入证书来解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ERROR: Cause: unable to find valid certification path to requested target终极解决方法](https://download.csdn.net/download/weixin_38646902/14036476)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Android Studio 打包生成APK文件及报错Cause: unable to find valid certification path to requested ...](https://blog.csdn.net/Z_X_L_/article/details/106826478)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值