PHP之curl请求方法的快捷封装函数 作者: lovingyu_er 时间: 2019-06-20 18:05:00 分类: PHP 评论 php使用curl 的get方法请求数据: ```php //***获取输出json内容的url,将json转为数组 function getCurl($url, $auth = false) { //echo $url; die(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $auth); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_TIMEOUT,10); //只需要设置一个秒的数量就可以 $output = @curl_exec($ch); if ($output === FALSE) { Ajax_Return('23', 'curl错误', curl_error($ch)); } curl_close($ch); unset($ch); return json_decode($output, true); } ``` 使用php 的post函数: ```php function postCurl($url,$requestData){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //普通数据 curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($requestData)); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); $res = curl_exec($curl); //$info = curl_getinfo($ch); curl_close($curl); return $res; } ``` option选项: CURLOPT_FOLLOWLOCATION: 当设置为TRUE 时将会根据服务器返回 HTTP 头中的 "Location: " 重定向。(注意:这是递归的,"Location: " 发送几次就重定向几次,除非设置了 CURLOPT_MAXREDIRS,限制最大重定向次数。)。
百度云盘可以 在Linux系统下使用了 作者: lovingyu_er 时间: 2019-06-17 18:33:00 分类: Ubuntu 评论 百度云盘官网最近发布了linux系统版本的客户端,下载链接: ```bash http://pan.baidu.com/download ``` 对于想要直接下载地址的,可以直接点击下载链接即可.这个是我在ubuntu 19.02上打包好的deb包: ```bash https://download.csdn.net/download/weixin_43118739/11245637 ``` tips:如果没有积分,请加我微信索取安装包! 大家发现下载的安装包是.rpm的,想要在ubuntu 以及debian下是不行的,所以需要对.rpm包进行处理。 关于rpm 转换成.deb文件,我们可以在ubuntu系统下通过alien安装包进行处理。 1.下载alien包:```bash sudo apt-get install alien ``` 2.下载 百度云盘的rpm包. 3.执行:```bash sudo alien baiduyunpan_pack.rpm ``` 4. 对于生成的新文件,直接执行:```bash sudo dpkg -i new_pack.deb ```
Ubuntu19.04系统提示libpcre3 (= 2:8.39-12) but 2:8.41-4+ubuntu14.04.1+deb.sury.org+1 is to be installe 作者: lovingyu_er 时间: 2019-06-11 23:26:00 分类: PHP,Ubuntu 评论 在学习```swoole``` 的时候,想通过```pecl install swoole``` 安装swoole 的扩展的时候,发现在命令行提示 ```pcel :command can't found ``` 的错误提示,查找问题原因原来是php7.2-dev没有安装,由于直接是通过apt源安装的php包(懒人安装法,没什么理由啦,编译安装的时间实在太久了),因此,向直接通过```sudo apt-get install php7.2-dev``` 安装软件包,发现报错,信息如下: `````bash darrykinger@darrykinger-MACHENIKE:~$ sudo apt-get install php7.2-dev Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: php7.2-dev : Depends: libpcre3-dev (>= 2:8.35) but it is not going to be installed E: Unable to correct problems, you have held broken packages. ``` 原来是提示缺少是libpcre3-dev ,想着那就安装吧,结果出现下面的问题: ````bash darrykinger@darrykinger-MACHENIKE:~$ sudo apt-get install libpcre3-dev Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: libpcre3-dev : Depends: libpcre3 (= 2:8.39-12) but 2:8.41-4+ubuntu14.04.1+deb.sury.org+1 is to be installed E: Unable to correct problems, you have held broken packages. ``` 脑袋瞬间就炸了,what ? 经过各种百度,得到一个提示,既然它想要的是2:8.39版本,但是我安装的是2:8-41-4的版本,那么我懒的卸载了,直接安装2:8.39-12版本就行了. 在百度中输入关键字libpcre3-dev 2:8.39-12 ,最后找到了ubuntu 的官方package 文档包,那么就直接在这个官网找这个包吧,最后在这个链接中```https://packages.ubuntu.com/disco/libpcre3```,中看到下面有关下载的链接,我的优于是amd64 架构的,  所以直接点击了下面的amd64下载了,如果你的下载速度比较慢,请根据网页的提示,找到最优质的下载源. 下载完成后,deb的安装很简单 直接```sudo dpkg -i libpcre3_8.39-12_amd64.deb``` 即可 执行```echo $?``` 发现输出的为0 ,说明没有问题, 直接执行```sudo apt-get install php7.2-dev ``` 然后执行```sudo pecl install swoole``` 发现安装成功. 至此,问题得到完整的解决,其实速度很快的,由于自己使用的是手机wifi ,速度各种龟速呀.:scream: :joy: :joy: :sob: :sob: ###补充: 如果上述最后的通过sudo pecl install swoole 不能成功,很可能是因为php7.2中的源还没有swoole扩展,那这个时候我们可以去swoole官网下载swoole ,下载后解压,进入解压包的根目录的下,直接执行phpize 生成configure 然后make ,make install 就可以了 ###另外 php的命令行扩展和php -m php-fpm 的扩展的开启方式是不一样的 命令行扩展请配置:```xxx/xxx/cli/php.ini``` php-fpm 扩展请配置```xxx/xxx/fpm/php.ini``` 前者不用重启,后者需要重启php-fpm 进程.
Linux 命令之查看系统可用的升级包 作者: lovingyu_er 时间: 2019-06-10 09:41:49 分类: Ubuntu 评论 Ubuntu 系统下,查看可以升级的软件包: ```bash sudo apt list --upgradeable ``` 命令执行以后出现: ```bash 正在列表... 完成 code/stable 1.35.0-1559611369 amd64 [可从该版本升级:1.34.0-1557957934] firefox-locale-en/disco-updates,disco-security 67.0.1+build1-0ubuntu0.19.04.1 amd64 [可从该版本升级:67.0+build2-0ubuntu0.19.04.1] firefox/disco-updates,disco-security 67.0.1+build1-0ubuntu0.19.04.1 amd64 [可从该版本升级:67.0+build2-0ubuntu0.19.04.1] gir1.2-mutter-4/disco-updates 3.32.1-2ubuntu1~19.04.1 amd64 [可从该版本升级:3.32.0+git20190410-1ubuntu1] gnome-control-center-data/disco-updates,disco-updates 1:3.32.2-0ubuntu1 all [可从该版本升级:1:3.32.1-1ubuntu4.1] gnome-control-center-faces/disco-updates,disco-updates 1:3.32.2-0ubuntu1 all [可从该版本升级:1:3.32.1-1ubuntu4.1] gnome-control-center/disco-updates 1:3.32.2-0ubuntu1 amd64 [可从该版本升级:1:3.32.1-1ubuntu4.1] gnome-shell-common/disco-updates,disco-updates 3.32.1-1ubuntu1~19.04.1 all [可从该版本升级:3.32.0+git20190410-1ubuntu1] gnome-shell/disco-updates 3.32.1-1ubuntu1~19.04.1 amd64 [可从该版本升级:3.32.0+git20190410-1ubuntu1] google-chrome-stable/stable 75.0.3770.80-1 amd64 [可从该版本升级:74.0.3729.169-1] libmutter-4-0/disco-updates 3.32.1-2ubuntu1~19.04.1 amd64 [可从该版本升级:3.32.0+git20190410-1ubuntu1] libnautilus-extension1a/disco-updates 1:3.32.1-0ubuntu0.19.04.0 amd64 [可从该版本升级:1:3.32.0-0ubuntu2] linux-signed-generic/disco-updates,disco-security 5.0.0.16.17 amd64 [可从该版本升级:5.0.0.15.16] mutter-common/disco-updates,disco-updates 3.32.1-2ubuntu1~19.04.1 all [可从该版本升级:3.32.0+git20190410-1ubuntu1] mutter/disco-updates 3.32.1-2ubuntu1~19.04.1 amd64 [可从该版本升级:3.32.0+git20190410-1ubuntu1] nautilus-data/disco-updates,disco-updates 1:3.32.1-0ubuntu0.19.04.0 all [可从该版本升级:1:3.32.0-0ubuntu2] nautilus/disco-updates 1:3.32.1-0ubuntu0.19.04.0 amd64 [可从该版本升级:1:3.32.0-0ubuntu2] yaru-theme-gnome-shell/disco-updates,disco-updates 19.04.3 all [可从该版本升级:19.04.2] yaru-theme-gtk/disco-updates,disco-updates 19.04.3 all [可从该版本升级:19.04.2] yaru-theme-icon/disco-updates,disco-updates 19.04.3 all [可从该版本升级:19.04.2] yaru-theme-sound/disco-updates,disco-updates 19.04.3 all [可从该版本升级:19.04.2] youdao-dict/xenial 1.1.0-1 amd64 [可从该版本升级:1.1.0-0~ubuntu] ```