• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Curl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Curl的典型用法代码示例。如果您正苦于以下问题:PHP Curl类的具体用法?PHP Curl怎么用?PHP Curl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Curl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  * 初始化
  */
 public static function init()
 {
     $object = new Curl();
     $object->cookiePath();
     //初始cookie路径
     return $object;
 }
开发者ID:huangxinchun,项目名称:phalcon-modules,代码行数:10,代码来源:Curl.php


示例2: nextSong

 /**
  * get the next song in the playlist
  */
 private function nextSong()
 {
     $curl = new Curl();
     $songArray = $curl->getArray("http://8tracks.com/sets/" . $this->playToken . "/next?mix_id=" . $this->mixId . "&api_version=2&format=jsonh");
     $status = $songArray["status"];
     if (!preg_match('/(200)/', $status)) {
         if (preg_match('/(403)/', $status)) {
             $this->output->error("8tracks made a boo boo. (" . $status . ")", 403);
         } else {
             $this->output->error("8tracks made a boo boo. (" . $status . ")");
         }
     }
     if (isset($songArray["set"]["track"]["id"])) {
         $songId = $songArray["set"]["track"]["id"];
         $title = $songArray["set"]["track"]["name"];
         $artist = $songArray["set"]["track"]["performer"];
         $album = $songArray["set"]["track"]["release_name"];
         $duration = $songArray["set"]["track"]["play_duration"];
         $songUrl = $songArray["set"]["track"]["url"];
         $song = $this->db->select("SELECT mixId FROM 8tracks_playlists_songs WHERE mixId=? AND songId=? LIMIT 1", array($this->mixId, $songId), array("%d", "%d"));
         if (empty($song)) {
             $this->db->insert("8tracks_playlists_songs", array("mixId" => $this->mixId, "songId" => $songId, "trackNumber" => $this->trackNumber), array("%d", "%d", "%d"));
             $song = $this->db->select("SELECT songId FROM 8tracks_songs WHERE songId=? LIMIT 1", array($songId), array("%d"));
             if (empty($song)) {
                 $this->db->insert("8tracks_songs", array("songId" => $songId, "title" => $title, "artist" => $artist, "album" => $album, "duration" => $duration, "songUrl" => $songUrl), array("%d", "%s", "%s", "%s", "%d", "%s"));
             }
         }
     } else {
         $this->output->error("That's all we could find.");
     }
 }
开发者ID:5eiko,项目名称:psychic-rotary-phone,代码行数:34,代码来源:EightTracks.php


示例3: getIp

 public static function getIp()
 {
     $co = new Curl(self::$ifconfigIp);
     $co->setopt(CURLOPT_RETURNTRANSFER, true);
     $ip = $co->exec();
     return $ip;
 }
开发者ID:braph,项目名称:dottk,代码行数:7,代码来源:ifconfig.php


示例4: getProblemInfo

 public static function getProblemInfo($problemId)
 {
     // 新建一个curl
     $ch = new Curl();
     $url = 'http://acm.hdu.edu.cn/showproblem.php?pid=' . $problemId;
     $html = $ch->get($url);
     if (empty($html) || $ch->error()) {
         $ch->close();
         return false;
     }
     $ch->close();
     $problemInfo = array();
     $matches = array();
     // 获取标题
     preg_match('/<td align=center><h1 style=\'color:#1A5CC8\'>(.*)<\\/h1>/sU', $html, $matches);
     $problemInfo['title'] = '';
     if (!empty($matches[1])) {
         $problemInfo['title'] = trim($matches[1]);
         $problemInfo['title'] = iconv('GBK', 'UTF-8', $problemInfo['title']);
     }
     // 获取来源
     preg_match('/>Source.*<a.*\\/search.php.*>(.*)<\\/a>/sU', $html, $matches);
     $problemInfo['source'] = '';
     if (!empty($matches[1])) {
         $problemInfo['source'] = trim($matches[1]);
         $problemInfo['source'] = iconv('GBK', 'UTF-8', $problemInfo['source']);
     }
     $problemInfo['problem_id'] = $problemId;
     $problemInfo['problem_code'] = $problemId;
     return $problemInfo;
 }
开发者ID:aozhongxu,项目名称:web_hqoj,代码行数:31,代码来源:HduRemoteAdapter.class.php


示例5: safeRemove

 /**
  * @param Curl $ch
  *
  * @throws \Exception
  */
 private function safeRemove(Curl $ch)
 {
     $return = curl_multi_remove_handle($this->multiHandle, $ch->getHandle());
     if ($return !== 0) {
         throw new \Exception('Error occurred: ' . $return);
     }
 }
开发者ID:chenshuhao,项目名称:BeginShake,代码行数:12,代码来源:MultiCurl.php


示例6: expressTakeUp

 public function expressTakeUp($userID, $expressID)
 {
     $curl = new Curl();
     $data = array("expressID" => $expressID, "userID" => $userID);
     $curl->post($this->url['expressTake'], $data);
     return $curl->response;
 }
开发者ID:aslijiasheng,项目名称:jasongo,代码行数:7,代码来源:express_service_model.php


示例7: getProblemInfo

 public static function getProblemInfo($problemId)
 {
     // 新建一个curl
     $ch = new Curl();
     $url = 'http://poj.org/problem?id=' . $problemId;
     $html = $ch->get($url);
     if (empty($html) || $ch->error()) {
         $ch->close();
         return false;
     }
     $ch->close();
     $problemInfo = array();
     $matches = array();
     // 获取标题
     preg_match('/<div class="ptt" lang="en-US">(.*)<\\/div>/sU', $html, $matches);
     $problemInfo['title'] = '';
     if (!empty($matches[1])) {
         $problemInfo['title'] = trim($matches[1]);
     }
     // 获取来源
     preg_match('/<a href="searchproblem\\?field=source.*>(.*)<\\/a>/sU', $html, $matches);
     $problemInfo['source'] = '';
     if (!empty($matches[1])) {
         $problemInfo['source'] = trim($matches[1]);
     }
     $problemInfo['problem_id'] = $problemId;
     $problemInfo['problem_code'] = $problemId;
     return $problemInfo;
 }
开发者ID:aozhongxu,项目名称:web_hqoj,代码行数:29,代码来源:PojRemoteAdapter.class.php


示例8: testValidatedSsl

 function testValidatedSsl()
 {
     $curl = new Curl();
     $curl->setValidateSsl(true);
     $response = $curl->get('https://www.facebook.com/');
     $this->assertEquals(200, $response->headers['Status-Code']);
 }
开发者ID:nickl-,项目名称:curl,代码行数:7,代码来源:CurlTest.php


示例9: doRequest

 public function doRequest($url)
 {
     $url = Util::sanitizeURL($url);
     if (false && !Util::validateURL($url)) {
         $response = array('errorCode' => 1008, 'errorMsg' => _('Invalid url') . $url);
         $this->sendJSON($response);
     }
     $curl = new Curl($url);
     // real url after all redirects.
     $url = $curl->getRealUrl();
     $qid = Util::generateQid($url);
     $outfile = Config::$outputDir . "/{$qid}.png";
     if (!file_exists($outfile)) {
         if (!$curl->isReachable()) {
             $response = array('errorCode' => 1009, 'errorMsg' => _('Site is unreachable please try again later'));
             $this->sendJSON($response);
         }
     }
     if ($this->queueRequest($qid, $url)) {
         Log::info("Queue {$url}");
         $response = array('items' => array(array('title' => $curl->getTitle(), 'qid' => $qid)));
         $this->sendJSON($response);
     } else {
         $response = array('errorCode' => 1009, 'errorMsg' => sprintf(_('Error: %s'), $this->db->error));
         $this->sendJSON($response);
     }
 }
开发者ID:rhalff,项目名称:Websnapit,代码行数:27,代码来源:websnap.php


示例10: initialize

 function initialize()
 {
     if (!$this->fetched) {
         $config =& get_config();
         $assetUrl = $config['asset_service'] . $this->node['AssetID'];
         $curl = new Curl();
         $curl->create($assetUrl);
         $curl->option(CURLOPT_HEADER, true);
         $curl->option(CURLOPT_NOBODY, true);
         $response = $curl->execute();
         if ($response) {
             $headers = http_parse_headers($response);
             $this->size = $headers['Content-Length'];
             $this->contentType = $headers['Content-Type'];
             if (isset($headers['ETag'])) {
                 $this->etag = $headers['ETag'];
             } else {
                 if (isset($headers['Etag'])) {
                     $this->etag = $headers['Etag'];
                 } else {
                     $this->etag = '';
                 }
             }
         } else {
             log_message('error', "InventoryFile: Failed to fetch headers from {$assetUrl}");
         }
         $this->fetched = true;
     }
 }
开发者ID:QuillLittlefeather,项目名称:mgm-simiangrid,代码行数:29,代码来源:Class.InventoryFile.php


示例11: test_error

 function test_error()
 {
     assert_throws('CurlException', function () {
         $curl = new Curl();
         $curl->get('diaewkaksdljf-invalid-url-dot-com.com');
     });
 }
开发者ID:leebivip,项目名称:dns,代码行数:7,代码来源:curl_test.php


示例12: get

 public function get($url_mixed, $data = array())
 {
     if (is_array($url_mixed)) {
         $curl_multi = curl_multi_init();
         $this->_multi_parent = true;
         $this->curls = array();
         foreach ($url_mixed as $url) {
             $curl = new Curl();
             $curl->_multi_child = true;
             $curl->setOpt(CURLOPT_URL, $this->_buildURL($url, $data), $curl->curl);
             $curl->setOpt(CURLOPT_HTTPGET, true);
             $this->_call($this->_before_send, $curl);
             $this->curls[] = $curl;
             $curlm_error_code = curl_multi_add_handle($curl_multi, $curl->curl);
             if (!($curlm_error_code === CURLM_OK)) {
                 //throw new \ErrorException('cURL multi add handle error: ' .curl_multi_strerror($curlm_error_code));
             }
         }
         foreach ($this->curls as $ch) {
             foreach ($this->_options as $key => $value) {
                 $ch->setOpt($key, $value);
             }
         }
         do {
             $status = curl_multi_exec($curl_multi, $active);
         } while ($status === CURLM_CALL_MULTI_PERFORM || $active);
         foreach ($this->curls as $ch) {
             $this->exec($ch);
         }
     } else {
         $this->setopt(CURLOPT_URL, $this->_buildURL($url_mixed, $data));
         $this->setopt(CURLOPT_HTTPGET, true);
         return $this->exec();
     }
 }
开发者ID:AlexBGD,项目名称:DrKaske,代码行数:35,代码来源:Curl.php


示例13: CallMethod

 /**
  * Вызов метода ApiVK
  * @param $sMethod
  * @param $mParams
  * @return bool|mixed
  */
 private function CallMethod($sMethod, $mParams)
 {
     if (is_array($mParams)) {
         if (!isset($mParams['access_token'])) {
             if (!$this->sAccessToken) {
                 return false;
             }
             $mParams['access_token'] = $this->sAccessToken;
         }
         $oCurl = new Curl();
         $oCurl->SetUrl('https://api.vk.com/method/' . $sMethod);
         $oCurl->SetPostfields($mParams);
         $sResult = $oCurl->GetResponseBody(true);
     } else {
         $sParams = $mParams;
         if (!strpos($mParams, 'access_token')) {
             if (!$this->sAccessToken) {
                 return false;
             }
             $sParams = $mParams . '&access_token=' . $this->sAccessToken;
         }
         $oCurl = new Curl();
         $oCurl->SetUrl('https://api.vk.com/method/' . $sMethod . '?' . $sParams);
         $sResult = $oCurl->GetResponseBody(true);
     }
     if ($sResult === false) {
         throw new Exception($oCurl->Error());
     }
     $oCurl->close();
     return json_decode($sResult);
 }
开发者ID:lunavod,项目名称:bunker_stable,代码行数:37,代码来源:Vk.class.php


示例14: fAlamat

function fAlamat($lat = 0, $lon = 0)
{
    include_once './curl.class.php';
    $curl = new Curl();
    //	$a = $curl->post('http://ws.geonames.org/extendedFindNearby?lng='.$lon.'&lat='.$lat);
    $a = $curl->post('http://maps.google.com/maps/geo?q=' . $lat . ',' . $lon . '&gl=id&output=xml');
    /*	
    	$r["negara"] 	= $a["geonames"]["geoname"][2]["name"];
    	$r["propinsi"] 	= $a["geonames"]["geoname"][3]["name"];
    	$r["kota"]		= $a["geonames"]["geoname"][4]["name"];
    */
    $r["koordinat"] = $a['kml']['Response']['name'];
    $r["alamat"] = $a['kml']['Response']['Placemark']['address'];
    $r["negara"] = $a['kml']['Response']['Placemark']['AddressDetails']['Country']['CountryName'];
    $r["propinsi"] = $a['kml']['Response']['Placemark']['AddressDetails']['Country']['AdministrativeArea']['AdministrativeAreaName'];
    //if (empty($a['kml']['Response']['Placemark']['AddressDetails']['Country']['AdministrativeArea']['SubAdministrativeArea']['SubAdministrativeAreaName'])){
    $r["kota"] = $a['kml']['Response']['Placemark']['AddressDetails']['Country']['AdministrativeArea']['SubAdministrativeArea']['Locality']['LocalityName'];
    $r["daerah"] = $a['kml']['Response']['Placemark']['AddressDetails']['Country']['AdministrativeArea']['SubAdministrativeArea']['Locality']['DependentLocalityName'];
    $r["jalan"] = $a['kml']['Response']['Placemark']['AddressDetails']['Country']['AdministrativeArea']['SubAdministrativeArea']['Locality']['Thoroughfare']['ThoroughfareName'];
    //} else {
    //	$r["kota"]			= $a['kml']['Response']['Placemark']['AddressDetails']['Country']['AdministrativeArea']['SubAdministrativeArea']['Locality']['LocalityName'] . "," . $a['kml']['Response']['Placemark'][0]['AddressDetails']['Country']['AdministrativeArea']['SubAdministrativeArea']['SubAdministrativeAreaName'];
    //	$r["daerah"]		= $a['kml']['Response']['Placemark']['AddressDetails']['Country']['AdministrativeArea']['SubAdministrativeArea']['Locality']['DependentLocality']['DependentLocalityName'];
    //	$r["jalan"]			= $a['kml']['Response']['Placemark']['AddressDetails']['Country']['AdministrativeArea']['SubAdministrativeArea']['Locality']['DependentLocality']['Thoroughfare']['ThoroughfareName'];
    //}
    return $r;
}
开发者ID:nurulimamnotes,项目名称:Web-Tracking,代码行数:26,代码来源:inc.functions.php


示例15: webservice_post

function webservice_post($url, $params, $jsonRequest = FALSE)
{
    // Parse the RequestMethod out of the request for debugging purposes
    if (isset($params['RequestMethod'])) {
        $requestMethod = $params['RequestMethod'];
    } else {
        $requestMethod = '';
    }
    if (empty($url)) {
        log_message('error', "Canceling {$requestMethod} POST to an empty URL");
        return array('Message' => 'Web service URL is not configured');
    }
    if ($jsonRequest) {
        $params = json_encode($params);
    }
    // POST our query and fetch the response
    $curl = new Curl();
    $response = $curl->simple_post($url, $params);
    //log_message('debug', sprintf('Response received from %s POST to %s: %s', $requestMethod, $url, $response));
    // JSON decode the response
    $response = json_decode($response, TRUE);
    if (!isset($response)) {
        $response = array('Message' => 'Invalid or missing response');
    }
    return $response;
}
开发者ID:ronfesta,项目名称:simiangrid,代码行数:26,代码来源:index.php


示例16: execute

 public function execute()
 {
     $curl_options = array(CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_URL => $this->generate_url());
     $curl = new Curl($curl_options);
     $res = $curl->execute();
     return json_decode($res);
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:7,代码来源:Url_Shortner.php


示例17: post

function post($url, $data)
{
    $curlObj = new Curl();
    $curlObj->setUrl($url);
    $curlObj->setPost($data);
    return $curlObj->run();
}
开发者ID:playgamelxh,项目名称:lxh,代码行数:7,代码来源:index.php


示例18: process_user

 public function process_user($username, $password, $facility_code)
 {
     $curl = new Curl();
     $response = array();
     //Get Supplier
     $supplier = $this->get_supplier($facility_code);
     if ($supplier == "kemsa") {
         //Use nascop url
         $url = $this->default_url;
         $post = array("email" => $username, "password" => $password);
         $url = $this->default_url . 'sync/user';
         $curl->post($url, $post);
     } else {
         //Use escm url
         $curl->setBasicAuthentication($username, $password);
         $curl->setOpt(CURLOPT_RETURNTRANSFER, TRUE);
         $url = $this->default_url . 'user/' . $username;
         $curl->get($url);
     }
     //Handle Response
     if ($curl->error) {
         $response['error'] = TRUE;
         $response['content'] = array($curl->error_code);
     } else {
         $response['error'] = FALSE;
         $response['content'] = json_decode($curl->response, TRUE);
     }
     return json_encode($response);
 }
开发者ID:OmondiKevin,项目名称:ADT_MTRH,代码行数:29,代码来源:cdrr_logic.php


示例19: getToken

 public function getToken()
 {
     $username = self::CONFIG_USERNAME;
     $password = self::CONFIG_PASSWORD;
     $time = time();
     $hash = md5("{$username}@{$password}@{$time}");
     $auth = "{$username}@{$time}@{$hash}";
     $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
     $url = 'http://axe.mappy.com/1v1/token/generate.aspx?' . 'auth=' . urlencode($auth) . '&' . 'ip=' . urldecode($ip);
     /**
             $remote = @fopen($url, 'rb');
     
             if ( false === $remote )
        return false;
     
             $token = '';
     
             while ( !( feof($remote) ) )
        $token .= fread($remote, 8192);
     
             fclose($remote);
     */
     $curl = new Curl($url);
     $curl->request();
     $resp = $curl->response();
     $curl->disconnect();
     return $resp['body'];
 }
开发者ID:joksnet,项目名称:php-old,代码行数:28,代码来源:Mappy.php


示例20: postUpdateCard

 public function postUpdateCard()
 {
     // Add Curl library
     require_once app_path() . "/libraries/Curl/Curl.php";
     // Get Product
     $product = Product::where('code', Input::get('code'))->first();
     // Get Expiry month and year
     $expiry = explode(' / ', Input::get('ccExpire'));
     // Put all values in session
     Session::flash('ccNum', Input::get('ccNum'));
     Session::flash('ccExpire', Input::get('ccExpire'));
     Session::flash('ccCVC', Input::get('ccCVC'));
     $data = array('email' => Input::get('email'), 'code' => Input::get('code'), 'number' => Input::get('ccNum'), 'exp_month' => !empty($expiry[0]) ? $expiry[0] : NULL, 'exp_year' => !empty($expiry[1]) ? $expiry[1] : NULL, 'cvc' => Input::get('ccCVC'));
     $data['key'] = DKHelpers::GenerateHash($data, $product->api_key);
     $url = url() . "/api/v1/update-card";
     // Post data to IPN
     $curl = new Curl();
     $response = $curl->simple_post($url, $data, array(CURLOPT_BUFFERSIZE => 10));
     $response = json_decode($response);
     if (empty($response->error)) {
         $success = "Your card (**** **** **** {$response->last4}) has been updated successfully.";
         return Redirect::back()->with('success', $success);
     } else {
         return Redirect::back()->with('error', $response->error);
     }
 }
开发者ID:michaelotto126,项目名称:dksolution,代码行数:26,代码来源:CustomersController.php



注:本文中的Curl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Currency类代码示例发布时间:2022-05-23
下一篇:
PHP CsviHelper类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap