当前位置: 首页>>代码示例>>PHP>>正文


PHP curl函数代码示例

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


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

示例1: fetch_tweets

function fetch_tweets($num_tweets, $user_name, $tweet_reset_time)
{
    $tweets = curl("https://api.twitter.com/1.1/statuses/user_timeline.json");
    echo "<pre>";
    print_r($tweets);
    echo "</pre>";
}
开发者ID:stevenay,项目名称:wordpress,代码行数:7,代码来源:index.php

示例2: curl

/**
 *
 * @param string $url
 * @param array $post_data
 * @param string $proxy
 * @param int $max_loop
 * @return mixed
 */
function curl($url, $post_data = '', $proxy = '', $max_loop = 1)
{
    $ch = curl_init();
    $options = array(CURLOPT_USERAGENT => "GameCurl", CURLOPT_TIMEOUT => 10, CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $url, CURLOPT_FOLLOWLOCATION => true, CURLOPT_PROXY => '', CURLOPT_HTTPHEADER => array("Expect:"));
    //代理
    if ($proxy) {
        $options[CURLOPT_PROXY] = $proxy;
        $options[CURLOPT_PROXYTYPE] = CURLPROXY_SOCKS5;
    }
    //post
    if ($post_data) {
        $options[CURLOPT_POST] = true;
        $options[CURLOPT_POSTFIELDS] = $post_data;
    }
    curl_setopt_array($ch, $options);
    $result = curl_exec($ch);
    if (false === $result || curl_errno($ch)) {
        $max_loop++;
        if ($max_loop <= 3) {
            $result = curl($url, $post_data, $proxy, $max_loop);
        }
    }
    curl_close($ch);
    return $result;
}
开发者ID:cfhb,项目名称:script,代码行数:33,代码来源:track_log.php

示例3: parse_archive

 public function parse_archive(Archive $archive)
 {
     if ($archive->cover_mode) {
         return [$this->get_image_by_cover($archive->cover)];
     }
     $result = curl($archive->url, curl_options($this->domain));
     $archivePQ = \phpQuery::newDocumentHTML($result['data']);
     $content = $archivePQ['#content'];
     $title = $content['.entry-title']->html();
     $imgs = $content['.entry-content']->html();
     if (preg_match_all('#' . $this->domain . 'wp-content/[^"]*#', $imgs, $matches)) {
         $archive->images = array_merge(array_unique($matches[0]));
     }
     if (!$archive->images) {
         $title = $content['.main-title']->html();
         $imgs = $content['.main-body']->html();
         if (preg_match_all('#<a[^>]+href="(' . $this->domain . 'wp-content/[^"]*)">#', $imgs, $matches)) {
             $archive->images = array_merge(array_unique($matches[1]));
         }
     }
     if (strtolower($this->charset) != strtolower($GLOBALS['app_config']['charset'])) {
         $archive->title = iconv(strtoupper($this->charset), strtoupper($GLOBALS['app_config']['charset']) . '//IGNORE', $title);
     }
     $archive->title = $title;
 }
开发者ID:shfeat,项目名称:php-image-spider,代码行数:25,代码来源:Atfield.php

示例4: odeonCurl

function odeonCurl()
{
    $data = curl("http://www.odeoncinemas.ie/");
    $rzkR = str_replace('value="', "rzk", $data);
    preg_match_all('~rzk\\d+\\">\\w+[^<]*~', $rzkR, $arrayhold);
    for ($i = 0; $i < count($arrayhold[0]); $i++) {
        $removeRZ[$i] = str_replace('rzk', "", $arrayhold[0][$i]);
    }
    for ($i = 0; $i < count($removeRZ); $i++) {
        $removeQuote[$i] = str_replace('">', " ", $removeRZ[$i]);
    }
    for ($i = 0; $i < count($removeRZ); $i++) {
        if (preg_match("~\\d+~", $removeQuote[$i], $arraytemp)) {
            $m[$i]['id'] = $arraytemp;
        }
        if (preg_match("~^(\\w+)s*(.*)~", $removeQuote[$i], $arraytemp5)) {
            $m[$i]['location'] = $arraytemp5;
        }
    }
    for ($i = 1; $i < count($removeRZ); $i++) {
        $arr6[$i]['location'] = $m[$i]['location'][2];
        $arr6[$i]['id'] = $m[$i]['location'][1];
    }
    return $arrayhold;
}
开发者ID:Rcal,项目名称:cineStack2,代码行数:25,代码来源:cURLOd.php

示例5: create_site

 private static function create_site()
 {
     $site = current_site();
     $request = 'http://' . self::$api_urls[$_SERVER['SERVER_ADDR']] . '/?module=API&method=SitesManager.addSite&urls[]=http://' . rawurlencode($_SERVER['HTTP_HOST']) . '/&siteName=' . rawurlencode($site->name) . '&format=XML&token_auth=' . self::$auth_token;
     $result = simplexml_load_string(curl($request));
     return intval($result);
 }
开发者ID:kidaa30,项目名称:Swevers,代码行数:7,代码来源:piwik.php

示例6: refresh_token

 function refresh_token()
 {
     $client_id = $this->setting['taobao_appkey'];
     //自己的APPKEY
     $client_secret = $this->setting['taobao_appsecret'];
     //自己的appsecret
     $refresh_token = $this->setting['tao_session'];
     //refresh_token
     $grant_type = 'refresh_token';
     //请求参数
     $postfields = array('grant_type' => $grant_type, 'client_id' => $client_id, 'client_secret' => $client_secret, 'refresh_token' => $refresh_token);
     $url = 'https://oauth.taobao.com/token';
     $token = get_object_vars_final(json_decode(curl($url, $postfields)));
     print_r($token);
     if (!is_array($token)) {
         $this->error('对不起,授权失败,授权不可用', U('items_collect/author_tao'));
     }
     if (isset($token['error'])) {
         if ($token['error_description'] == 'refresh times limit exceed') {
             $this->error('对不起,授权失败,自动刷新淘宝授权可用', U('items_collect/author_tao'));
             //jump(-1,'自动刷新淘宝授权可用');
         } else {
             $this->error('对不起,检测失败,请从新获取淘宝授权后再检测', U('items_collect/author_tao'));
         }
     }
     if (urldecode($token['taobao_user_nick']) == $this->setting['taobao_nick']) {
         $this->success('恭喜您,授权成功', U('items_collect/author_tao'));
     } else {
         $this->error('对不起,授权失败,请核对后台淘宝账号是否正确', U('items_collect/author_tao'));
     }
     exit;
 }
开发者ID:chenyongze,项目名称:januarybuy_develop,代码行数:32,代码来源:taoOauthAction.class.php

示例7: access

 public function access()
 {
     $consumer_key = '10467-0ed56679a754835ac1e15622';
     $redirect_url = U('/API/access@ideat.org');
     $request_url = "https://getpocket.com/v3/oauth/request";
     $authorize_url = 'https://getpocket.com/v3/oauth/authorize';
     if (!session('?request_token')) {
         $post_data = array("consumer_key" => $consumer_key, "redirect_uri" => $redirect_url);
         $post_data = json_encode($post_data);
         $result = curl($request_url, $post_data);
         $request_token = $result['code'];
         session('request_token', $request_token);
         $authorize_url = "https://getpocket.com/auth/authorize?request_token={$request_token}&redirect_uri={$redirect_url}";
         redirect($authorize_url);
     } else {
         $request_token = session('request_token');
         session('request_token', null);
         $post_data = array("consumer_key" => $consumer_key, "code" => $request_token);
         $post_data = json_encode($post_data);
         $result = curl($authorize_url, $post_data);
         $access_token = $result['access_token'];
         session('access_token', $access_token);
         session('username', $result['username']);
         R('pocket');
     }
 }
开发者ID:ysking,项目名称:commlib,代码行数:26,代码来源:APIAction.class.php

示例8: curl

function curl($url)
{
    $ch = curl_init();
    // Initialising cURL
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_URL, $url);
    // Setting cURL's URL option with the $url variable passed into the function
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    // Setting cURL's option to return the webpage data
    $data = curl_exec($ch);
    // Executing the cURL request and assigning the returned data to the $data variable
    $info = curl_getinfo($ch);
    // $curr = curl_errno($ch);
    // print_r($curr);
    // print_r($info);
    if ($info['http_code'] == 301 && $info['redirect_url']) {
        $response = curl($info['redirect_url']);
    }
    curl_close($ch);
    // Closing cURL
    if (!$response) {
        $response['HTML'] = $data;
        $response['code'] = $info['http_code'];
    }
    return $response;
    // Returning the data from the function
}
开发者ID:cole007,项目名称:fitba,代码行数:27,代码来源:index.php

示例9: getKillsByPilot

function getKillsByPilot($id)
{
    $isSuper = 0;
    $url = "https://zkillboard.com/api/characterID/" . $id . "/orderDirection/desc/no-items/limit/1";
    $kills = curl($url);
    if ($kills[0]->victim->characterID != $id) {
        foreach ($kills[0]->attackers as $attacker) {
            if ($attacker->characterID == $id) {
                //only supers/titans
                $id = $attacker->shipTypeID;
                if ($id == 11567 || $id == 671 || $id == 23773 || $id == 3764 || $id == 23919 || $id == 22852 || $id == 23913 || $id == 23917 || $id == 3514) {
                    $isSuper = 1;
                    echo "Superpilot!: " . $attacker->characterName;
                } else {
                    echo "No Superpilot: " . $attacker->characterName;
                }
                break;
            }
        }
    } else {
        echo "No Superpilot: " . $kills[0]->victim->characterName;
    }
    echo "<br>";
    flush();
    return $isSuper;
}
开发者ID:Shegox,项目名称:WatchListForEvE,代码行数:26,代码来源:getLastKillsByPilot_3.php

示例10: _getItemAsHTML

 /** get the single entry of the list view as HTML
  * this method returns the single entry in HTML-Code
  *
  * @returns string $item as HMTL
  *
  * @param object item     the single list entry
  * @author CommSy Development Group
  */
 function _getItemAsHTML($item)
 {
     $html = LF . '<!-- BEGIN OF HOMEPAGE ITEM MOVE -->' . LF;
     $homepage_manager = $this->_environment->getHomepageManager();
     $father_list = $homepage_manager->getFatherItemList($this->_item->getItemID());
     if (!$father_list->isEmpty()) {
         $father_count = $father_list->getCount();
         $father_item = $father_list->getFirst();
         $padding = 30;
         while ($father_item) {
             $title = $father_item->getTitle();
             if ($father_item->isRootPage()) {
                 $title = $this->_translator->getMessage('HOMEPAGE_TITLE_ROOT_PAGE');
             }
             $html .= '<ul style="padding-left:' . $padding . 'px; margin:0px;"><li>' . $title . '</li></ul>' . LF;
             $padding = $padding + 20;
             $father_item = $father_list->getNext();
         }
         $father_item = $father_list->getLast();
         $html .= $this->_getChildrenAsHTML($father_item, $padding, $father_count);
     }
     // form
     $html .= '<form action="' . curl($this->_environment->getCurrentContextID(), $this->_environment->getCurrentModule(), $this->_environment->getCurrentFunction(), '') . '" method="post">' . LF;
     $html .= $this->_getHiddenFieldAsHTML('iid', $this->_item->getItemID());
     $html .= BRLF . $this->_getEndButtonAsHTML('option');
     $html .= '</form>' . LF;
     $html .= '<!-- END OF HOMEPAGE ITEM MOVE -->' . LF . LF;
     return $html;
 }
开发者ID:a2call,项目名称:commsy,代码行数:37,代码来源:cs_homepage_move_view.php

示例11: ftp_scandir

function ftp_scandir($opts, $pipe, $cmd = __FUNCTION__)
{
    # set up functions for curl to parse
    $req = array('curlopts' => array('ftplistonly' => true), 'finalize_functions' => array('curl_finalize_set_split_key'), 'finalize_curlopts' => array('ftplistonly' => false), 'path_is_dir' => true);
    # merge the opts and pass to curl for processing
    $opts = merge_opts_for_output($opts, $req);
    return curl($opts, $pipe, $cmd, 'ftp');
}
开发者ID:simpl,项目名称:datapipe,代码行数:8,代码来源:curl_ftp.php

示例12: imap_get_email_body

function imap_get_email_body($opts, $pipe, $cmd = __FUNCTION__)
{
    # set up functions for curl to parse
    $req = array('init_functions' => array('imap_check_mailbox', 'imap_check_email_id', 'imap_set_fetch_email_body'), 'finalize_functions' => array('imap_parse_email_body', 'imap_parse_email_body_parts'));
    # merge the opts and pass to curl for processing
    $opts = merge_opts_for_output($opts, $req);
    return curl($opts, $pipe, $cmd, 'imap');
}
开发者ID:simpl,项目名称:datapipe,代码行数:8,代码来源:curl_imap.php

示例13: AutoTranslate

function AutoTranslate($word)
{
    $word = urlencode($word);
    $url = 'http://translate.google.com/translate_a/t?client=t&text=' . $word . '&hl=en&sl=auto&tl=en&multires=1&otf=2&pc=1&ssel=0&tsel=0&sc=1';
    $name_en = curl($url);
    $name_en = explode('"', $name_en);
    return $name_en[1];
}
开发者ID:CityPulse,项目名称:Twitter,代码行数:8,代码来源:FreeGTranslat.php

示例14: Translate

function Translate($word, $conversion = 'hi_to_en')
{
    $word = urlencode($word);
    $url = 'http://translate.google.com/translate_a/t?client=t&text=' . $word . '&hl=en&sl=en&tl=hi&ie=UTF-8&oe=UTF-8&multires=1&otf=1&ssel=3&tsel=3&sc=1';
    $name_en = curl($url);
    $name_en = explode('"', $name_en);
    return $name_en[1];
}
开发者ID:nikunjsince92,项目名称:farming-QA-System--API-,代码行数:8,代码来源:showraw.php

示例15: nearestAirport

function nearestAirport($query)
{
    $connection = 'https://api.mongolab.com/api/1/databases/runaway/collections/';
    $key = '?apiKey=sCMaz0w9WNpWNg7zJm6rUc7pSmqq3phq';
    $queryString = json_encode($query);
    $result = curl($connection . 'airports' . $key . '&q=' . $queryString . '&fo=true');
    return json_decode($result, true);
}
开发者ID:evantzhao,项目名称:runaway,代码行数:8,代码来源:db_connect_web.php


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