Пример #1
0
 public function testRequestWithGetMethod()
 {
     $url = "http://v.juhe.cn/postcode/query";
     $data = array('postcode' => '310018', 'key' => '1c85799c8c1a6675fb8c312e4b7a09d3');
     $result = CurlToolkit::request('GET', $url, $data);
     $this->assertEquals(0, $result['error_code']);
 }
Пример #2
0
 public function downloadAction(Request $request)
 {
     $token = $request->query->get('token');
     $url = $request->request->get('url');
     $url = str_replace(' ', '%20', $url);
     $url = str_replace('+', '%2B', $url);
     $url = str_replace('#', '%23', $url);
     $maker = new UploadToken();
     $token = $maker->parse($token);
     if (empty($token)) {
         throw new \RuntimeException("上传授权码已过期,请刷新页面后重试!");
     }
     $name = date("Ymdhis") . "_formula.jpg";
     $path = $this->getServiceKernel()->getParameter('topxia.upload.public_directory') . '/tmp/' . $name;
     $imageData = CurlToolkit::request('POST', $url, array(), array('contentType' => 'plain'));
     $tp = @fopen($path, 'a');
     fwrite($tp, $imageData);
     fclose($tp);
     $record = $this->getFileService()->uploadFile($token['group'], new File($path));
     $url = $this->get('topxia.twig.web_extension')->getFilePath($record['uri']);
     return new Response($url);
 }
Пример #3
0
 private function changeLink($url)
 {
     $arrResponse = CurlToolkit::request('POST', "http://dwz.cn/create.php", array('url' => $url));
     if ($arrResponse['status'] != 0) {
         throw new \RuntimeException("短链接生成失败!");
     }
     $shortUrl = $arrResponse['tinyurl'] . ' ';
     return $shortUrl;
 }
Пример #4
0
 private function getNoticesFromOpen()
 {
     $url = "http://open.edusoho.com/api/v1/context/notice";
     return CurlToolkit::request('GET', $url);
 }
Пример #5
0
 public function changeLinkAction(Request $request)
 {
     $url = $request->getHost();
     $url .= $request->query->get('url');
     $arrResponse = CurlToolkit::request('POST', "http://dwz.cn/create.php", array('url' => $url));
     if ($arrResponse['status'] != 0) {
         $qqArrResponse = CurlToolkit::request('POST', "http://qqurl.com/create/", array('url' => $url));
         if ($qqArrResponse['status'] != 0) {
             return $this->createJsonResponse(array('url' => $url . ' '));
         } else {
             return $this->createJsonResponse(array('url' => $qqArrResponse['short_url'] . ' '));
         }
     } else {
         return $this->createJsonResponse(array('url' => $arrResponse['tinyurl'] . ' '));
     }
 }
Пример #6
0
 public function changeLinkAction(Request $request)
 {
     $url = $request->getHost();
     $url .= $request->query->get('url');
     $arrResponse = CurlToolkit::request('POST', "http://dwz.cn/create.php", array('url' => $url));
     if ($arrResponse['status'] != 0) {
         throw new \RuntimeException("短链接生成失败!");
     }
     $shortUrl = $arrResponse['tinyurl'] . ' ';
     return $this->createJsonResponse(array('url' => $shortUrl));
 }
Пример #7
0
 public function fetchAvatar($url)
 {
     return CurlToolkit::request('GET', $url, array(), array('contentType' => 'plain'));
 }
Пример #8
0
 private function changeLink($url)
 {
     $arrResponse = CurlToolkit::request('POST', "http://dwz.cn/create.php", array('url' => $url));
     if ($arrResponse['status'] != 0) {
         $qqArrResponse = CurlToolkit::request('POST', "http://qqurl.com/create/", array('url' => $url));
         if ($qqArrResponse['status'] != 0) {
             return $url . ' ';
         } else {
             return $qqArrResponse['short_url'] . ' ';
         }
     } else {
         return $arrResponse['tinyurl'] . ' ';
     }
 }