コード例 #1
0
ファイル: Owl.php プロジェクト: argentum88/owl-client
 public function request($url, $useOwlServer = true)
 {
     $url = urldecode($url);
     PH_DEBUG ? Debugger::dumpBar($url, 'url') : null;
     if ($useOwlServer) {
         $url = $this->getUrl($url);
         $request = new Request($url);
         $request->getOptions()->set(CURLOPT_TIMEOUT, 8)->set(CURLOPT_RETURNTRANSFER, true)->set(CURLOPT_USERAGENT, $this->di->get('config')->curlUserAgent);
         $response = $request->send();
         $content = json_decode($response->getContent(), true);
         $url = $this->getUrl('', 'common');
         $request = new Request($url);
         $request->getOptions()->set(CURLOPT_TIMEOUT, 8)->set(CURLOPT_RETURNTRANSFER, true)->set(CURLOPT_USERAGENT, $this->di->get('config')->curlUserAgent);
         $response = $request->send();
         $common = json_decode($response->getContent(), true);
         return $content + $common;
     }
     $response = Contents::get($url);
     return $response;
 }
コード例 #2
0
 public function forwardAction()
 {
     $uri = $this->request->getURI();
     $pos = strpos($uri, '#');
     if ($pos !== false) {
         $uri = substr($uri, 0, $pos);
     }
     $pos = strpos($uri, '?');
     if ($pos !== false) {
         $uri = substr($uri, 0, $pos);
         return $this->response->redirect($uri, false, 301);
     }
     $response = (new Owl())->request($uri, $this->config->useOwlServer);
     PH_DEBUG ? Debugger::dumpBar($response) : null;
     if ($response['success']) {
         if ($response['controller'] == 'redirect') {
             return $this->response->redirect($response['location'], false, $response['code']);
         }
         $this->dispatcher->forward(['controller' => $response['controller'], 'action' => $response['action'], 'params' => [$response]]);
     } else {
         $this->dispatcher->forward(['controller' => 'Error', 'action' => 'error404']);
     }
 }