From b2b47055af36ba378447ca2cbebbe5347d1abcec Mon Sep 17 00:00:00 2001 From: david Date: Sun, 12 Sep 2021 18:23:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E8=AE=BE=E7=BD=AEcu?= =?UTF-8?q?rl=E7=BB=84=E4=BB=B6=20301=E8=B7=9F=E9=9A=8F2=E6=AC=A1=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=93=B7=E5=99=A8=E3=80=81=E5=9F=8E=E5=B8=82?= =?UTF-8?q?=E7=AD=89=E7=AB=99=E7=82=B9=E7=9A=84=E8=B7=B3=E8=BD=AC=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/event}/EventDispatcher.php | 14 ++++++------- app/common/event/EventDispatcherInterface.php | 21 +++++++++++++++++++ .../common/event}/EventListenerInterface.php | 6 +++--- .../event}/ListenerProviderInterface.php | 6 +++--- .../common/event}/StoppableEventInterface.php | 2 +- src/Library/EventListen/send.php | 2 +- src/Rss/AbstractRss.php | 3 +++ 7 files changed, 39 insertions(+), 15 deletions(-) rename {src/Library/Event => app/common/event}/EventDispatcher.php (83%) create mode 100644 app/common/event/EventDispatcherInterface.php rename {src/Library/Event => app/common/event}/EventListenerInterface.php (71%) rename {src/Library/Event => app/common/event}/ListenerProviderInterface.php (76%) rename {src/Library/Event => app/common/event}/StoppableEventInterface.php (96%) diff --git a/src/Library/Event/EventDispatcher.php b/app/common/event/EventDispatcher.php similarity index 83% rename from src/Library/Event/EventDispatcher.php rename to app/common/event/EventDispatcher.php index 2cd2b5d..0c4678d 100644 --- a/src/Library/Event/EventDispatcher.php +++ b/app/common/event/EventDispatcher.php @@ -1,6 +1,6 @@ eventListeners[$class] ?? []; $iterable = []; foreach ($listeners as $listener) { @@ -53,11 +53,11 @@ class EventDispatcher implements ListenerProviderInterface /** * 派发当前事件到所有监听器的process处理方法 * - * @param string $event 当前事件对象 + * @param object $event 当前事件对象 * @return string * The Event that was passed, now modified by listeners. */ - public function dispatch(string $event) + public function dispatch(object $event) { foreach ($this->getListenersForEvent($event) as $callback) { try { diff --git a/app/common/event/EventDispatcherInterface.php b/app/common/event/EventDispatcherInterface.php new file mode 100644 index 0000000..a3cddeb --- /dev/null +++ b/app/common/event/EventDispatcherInterface.php @@ -0,0 +1,21 @@ +curl->setOpt(CURLOPT_SSL_VERIFYHOST, 2); // 检查证书 $this->curl->setOpt(CURLOPT_CONNECTTIMEOUT, self::CONNECTTIMEOUT); // 超时 $this->curl->setOpt(CURLOPT_TIMEOUT, self::TIMEOUT); // 超时 + $this->curl->setOpt(CURLOPT_FOLLOWLOCATION, 1); // 自动跳转,跟随请求Location + $this->curl->setOpt(CURLOPT_MAXREDIRS, 2); // 递归次数 $this->curl->setUserAgent(static::getUserAgent()); } @@ -290,6 +292,7 @@ abstract class AbstractRss echo $this->site." 正在请求RSS... {$url}". PHP_EOL; $url = (stripos($url, 'http://') === 0 || stripos($url, 'https://') === 0) ? $url : $this->host . $url; $res = $this->curl->get($url); + //cli($res);exit; if ($res->http_status_code == 200) { echo "RSS获取信息,成功!". PHP_EOL; return $res->response;