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


PHP curl::post方法代码示例

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


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

示例1: add_fields

 /**
  * Adds the provided fields to Solr schema.
  *
  * Intentionally separated from create(), it can be called to add extra fields.
  * fields separately.
  *
  * @throws \coding_exception
  * @throws \moodle_exception
  * @param  array $fields \core_search\document::$requiredfields format
  * @param  bool $checkexisting Whether to check if the fields already exist or not
  * @return bool
  */
 protected function add_fields($fields, $checkexisting = true)
 {
     if ($checkexisting) {
         // Check that non of them exists.
         $this->validate_fields($fields, false);
     }
     $url = $this->engine->get_connection_url('/schema');
     // Add all fields.
     foreach ($fields as $fieldname => $data) {
         if (!isset($data['type']) || !isset($data['stored']) || !isset($data['indexed'])) {
             throw new \coding_exception($fieldname . ' does not define all required field params: type, stored and indexed.');
         }
         // Changing default multiValued value to false as we want to match values easily.
         $params = array('add-field' => array('name' => $fieldname, 'type' => $data['type'] === 'text' ? 'text_general' : $data['type'], 'stored' => $data['stored'], 'multiValued' => false, 'indexed' => $data['indexed']));
         $results = $this->curl->post($url, json_encode($params));
         // We only validate if we are interested on it.
         if ($checkexisting) {
             if ($this->curl->error) {
                 throw new \moodle_exception('errorcreatingschema', 'search_solr', '', $this->curl->error);
             }
             $this->validate_add_field_result($results);
         }
     }
     return true;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:37,代码来源:schema.php

示例2: ip

 /**
  * ip地址查询
  */
 public function ip()
 {
     $ip = $this->post('ip');
     if (!$ip) {
         return;
     }
     $result = $ip_address = array();
     // tool.lu
     $toollu = curl::post('http://tool.lu/netcard/ajax.html', array('ip' => $ip));
     $toollu = json_decode($toollu, true);
     $result['tool.lu'] = trim($toollu['text'][2]);
     $result['纯真数据库'] = trim($toollu['text'][1]);
     // 站长工具
     $chinaz = curl::post('http://ip.chinaz.com', array('ip' => $ip));
     $chinaz = trim(preg_replace('/<.+?>/', '', $chinaz));
     $chinaz = explode('查询结果', $chinaz);
     if ($chinaz) {
         unset($chinaz[0]);
         $size = intval(count($chinaz));
         $chinaz[$size] = trim(substr($chinaz[$size], 0, strpos($chinaz[$size], 'document')));
         $address = '';
         foreach ($chinaz as $c) {
             $c = explode('==>>', $c);
             $ip_address_ = explode(':', trim($c[0]));
             $ip_address[] = trim($ip_address_[1]);
             $tmp_arr = explode("\r\n", trim($c[2]));
             $address .= trim($tmp_arr[0]) . '  ';
         }
         $result['站长工具'] = trim($address);
     }
     // 淘宝
     if ($ip_address) {
         $taobao = curl::get('http://ip.taobao.com/service/getIpInfo.php', array('ip' => $ip_address[0]));
         $taobao = json_decode($taobao, true);
         if (intval($taobao['code']) === 0) {
             $taobao = $taobao['data'];
             $result['淘宝'] = $taobao['country'] . '|' . $taobao['area'] . '|' . $taobao['region'] . '|' . $taobao['city'] . '|' . $taobao['isp'];
         }
     }
     // ipip.net
     if ($ip_address) {
         $ipip = curl::get('http://freeapi.ipip.net/' . $ip_address[0]);
         $ipip = json_decode($ipip, true);
         if (is_array($ipip)) {
             $ipipstr = '';
             foreach ($ipip as $str) {
                 $str = trim($str);
                 if (empty($str)) {
                     continue;
                 }
                 $ipipstr .= $str . ' ';
             }
             $result['ipip.net'] = $ipipstr;
         }
     }
     view::assign('input', $ip);
     view::assign('ip', $ip_address);
     view::assign('result', $result);
 }
开发者ID:luozhanhong,项目名称:share,代码行数:62,代码来源:server.php

示例3: query

 public function query($data)
 {
     global $CFG;
     require_once $CFG->libdir . '/filelib.php';
     $c = new curl();
     $options = array('returntransfer' => true);
     $result = $c->post($this->_gatewayURL, $data, $options);
     return $result;
 }
开发者ID:Regaez,项目名称:moodle-local_moodec,代码行数:9,代码来源:gateway_dps.php

示例4: post

 function post()
 {
     $service_url = 'http://www.andreseloysv.com/epg/response.php';
     $curl = curl_init($service_url);
     $curl_post_data = array('firstName' => $this->firstName, 'lastName' => $this->lastName, 'creditCardNumber' => $this->creditCardNumber, 'ccv' => $this->ccv, 'expiration_month' => $this->expiration_month, 'expiration_year' => $this->expiration_year, 'amount' => $this->amount);
     $sender = new curl($service_url, $curl_post_data);
     $result = $sender->post();
     return $result;
 }
开发者ID:andreseloysv,项目名称:epg,代码行数:9,代码来源:sendPayment.php

示例5: get_access_token

 /**
  * Request oauth access token from server
  * @param string $method
  * @param string $url
  * @param string $token
  * @param string $secret
  */
 public function get_access_token($token, $secret, $verifier = '')
 {
     $this->sign_secret = $this->consumer_secret . '&' . $secret;
     $params = $this->prepare_oauth_parameters($this->access_token_api, array('oauth_token' => $token, 'oauth_verifier' => $verifier), 'POST');
     $this->setup_oauth_http_header($params);
     $content = $this->http->post($this->access_token_api, $params);
     $keys = $this->parse_result($content);
     $this->set_access_token($keys['oauth_token'], $keys['oauth_token_secret']);
     return $keys;
 }
开发者ID:nigeli,项目名称:moodle,代码行数:17,代码来源:oauthlib.php

示例6: loginPortal

function loginPortal($user = '', $password = '')
{
    if (substr($user, 0, 2) !== 'cc') {
        $user = "cc" . $user;
        error_log($user . " , " . substr($user, 0, 2));
    }
    $logindata = array('wu_loginname' => urlencode($user), 'wu_password' => urlencode($password), 'Login' => urlencode('Inloggen'));
    $curl = curl::post('https://leerlingen.candea.nl/Login?passAction=login&path=%2F', $logindata, array(CURLOPT_HEADER => 1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_SSL_VERIFYPEER => false));
    if (strpos($curl, 'Inloggegevens onjuist') != 0 || strpos($curl, 'U heeft geen rechten') != 0) {
        return false;
    }
    return true;
}
开发者ID:CWMCDev,项目名称:Barend,代码行数:13,代码来源:auth.php

示例7: TokenWechat

 function handle_post()
 {
     if (is_array($this->josn_array)) {
         $json = json_encode($this->josn_array);
     }
     $token_obj = new TokenWechat(APPID, APPSECRET);
     $access_token = $token_obj->get_token();
     $url = sprintf('https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=%s', $access_token);
     import("curl.lib");
     $curl = new curl();
     $curl->setOpt(CURLOPT_RETURNTRANSFER, TRUE);
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE);
     $result = $curl->post($url, $json);
     return $result;
 }
开发者ID:00606,项目名称:wechat,代码行数:15,代码来源:service.wechat.php

示例8: classifyAndReportSpam

 /**
  * Classify a post as spam (and report it) or ham
  *
  * @param \mod_forum\event\post_created $event The event.
  * @return void
  */
 protected static function classifyAndReportSpam(\mod_forum\event\post_created $event)
 {
     $snapshot = $event->get_record_snapshot('forum_posts', $event->objectid);
     $text = $snapshot->subject . ' ' . $snapshot->message;
     $config = get_config('local_solr');
     $curl = new \curl();
     $result = $curl->post($config->spamclassifierhost . ':' . $config->spamclassifierport, array('text' => $text));
     if ($result_decoded = json_decode($result)) {
         if ($result_decoded['cat'] == 'spam') {
             require_once $CFG->dirroot . '/blocks/spam_deletion/lib.php';
             $postspam = new \forum_post_spam($event->objectid);
             $postspam->register_vote(2);
         }
     }
 }
开发者ID:danielneis,项目名称:moodle-local_solr,代码行数:21,代码来源:forum_observers.php

示例9: moodle_xmlrpc_call

function moodle_xmlrpc_call($functionname, $object)
{
    $serverurl = MOODLE_URL . '/webservice/xmlrpc/server.php' . '?wstoken=' . MOODLE_TOKEN;
    $curl = new curl();
    //var_dump($object);
    if (empty($object)) {
        return null;
    }
    $post = xmlrpc_encode_request($functionname, $object, array('encoding' => 'utf-8', 'escaping' => 'markup'));
    $resp = xmlrpc_decode($curl->post($serverurl, $post), 'utf-8');
    $error = get_xmlrpc_error($resp);
    if (empty($error)) {
        //handle the positive response
        return call_user_func($functionname . '_response', $resp);
    }
    return $error;
}
开发者ID:fabioassuncao,项目名称:rosariosis,代码行数:17,代码来源:client.php

示例10: sendOAuthBodyPOST

function sendOAuthBodyPOST($method, $endpoint, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $body)
{
    $hash = base64_encode(sha1($body, TRUE));
    $parms = array('oauth_body_hash' => $hash);
    $test_token = '';
    $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
    $test_consumer = new OAuthConsumer($oauth_consumer_key, $oauth_consumer_secret, NULL);
    $acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $test_token, $method, $endpoint, $parms);
    $acc_req->sign_request($hmac_method, $test_consumer, $test_token);
    // Pass this back up "out of band" for debugging
    global $LastOAuthBodyBaseString;
    $LastOAuthBodyBaseString = $acc_req->get_signature_base_string();
    // echo($LastOAuthBodyBaseString."\m");
    $headers = array();
    $headers[] = $acc_req->to_header();
    $headers[] = "Content-type: " . $content_type;
    $curl = new \curl();
    $curl->setHeader($headers);
    $response = $curl->post($endpoint, $body);
    return $response;
}
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:21,代码来源:OAuthBody.php

示例11: login

 public static function login($user = '', $password = '')
 {
     if (substr($user, 0, 2) !== 'cc') {
         $user = "cc" . $user;
         error_log($user . " , " . substr($user, 0, 2));
     }
     $logindata = array('wu_loginname' => urlencode($user), 'wu_password' => urlencode($password), 'Login' => urlencode('Inloggen'));
     $curl = curl::post('https://leerlingen.candea.nl/Login?passAction=login&path=%2F', $logindata, array(CURLOPT_HEADER => 1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_SSL_VERIFYPEER => false));
     if (strpos($curl, 'Inloggegevens onjuist') != 0) {
         return false;
     }
     preg_match('/^Set-Cookie:\\s*([^;]*)/mi', $curl, $cookies);
     parse_str($cookies[1], $cookies);
     $cookiestr = '';
     foreach ($cookies as $key => $val) {
         $cookiestr .= "{$key}={$val}; ";
     }
     self::$cookiestr = $cookiestr;
     setcookie("portal", $cookiestr, time() + 86400 * 30, "/");
     // 86400 = 1 day
     return true;
 }
开发者ID:CWMCDev,项目名称:Barend,代码行数:22,代码来源:portal_student.php

示例12: curl_request

 public function curl_request($action, $collection = null)
 {
     $curl = new curl();
     switch ($action) {
         case 'user':
             $url = $this->backpack . "/displayer/convert/email";
             $param = array('email' => $this->email);
             break;
         case 'groups':
             $url = $this->backpack . '/displayer/' . $this->backpackuid . '/groups.json';
             break;
         case 'badges':
             $url = $this->backpack . '/displayer/' . $this->backpackuid . '/group/' . $collection . '.json';
             break;
     }
     $options = array('FRESH_CONNECT' => true, 'RETURNTRANSFER' => true, 'FORBID_REUSE' => true, 'HEADER' => 0, 'HTTPHEADER' => array('Expect:'), 'CONNECTTIMEOUT' => 3);
     if ($action == 'user') {
         $out = $curl->post($url, $param, $options);
     } else {
         $out = $curl->get($url, array(), $options);
     }
     return json_decode($out);
 }
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:23,代码来源:backpacklib.php

示例13: do_request

 /**
  * Send the request via our curl object.
  *
  * @param curl $curl prepared curl object.
  * @param Google_HttpRequest $request The request.
  * @return string result of the request.
  */
 private function do_request($curl, $request)
 {
     $url = $request->getUrl();
     $method = $request->getRequestMethod();
     switch (strtoupper($method)) {
         case 'POST':
             $ret = $curl->post($url, $request->getPostBody());
             break;
         case 'GET':
             $ret = $curl->get($url);
             break;
         case 'HEAD':
             $ret = $curl->head($url);
             break;
         case 'PUT':
             $ret = $curl->put($url);
             break;
         default:
             throw new coding_exception('Unknown request type: ' . $method);
             break;
     }
     return $ret;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:30,代码来源:curlio.php

示例14: download_file_content

/**
 * Fetches content of file from Internet (using proxy if defined). Uses cURL extension if present.
 * Due to security concerns only downloads from http(s) sources are supported.
 *
 * @category files
 * @param string $url file url starting with http(s)://
 * @param array $headers http headers, null if none. If set, should be an
 *   associative array of header name => value pairs.
 * @param array $postdata array means use POST request with given parameters
 * @param bool $fullresponse return headers, responses, etc in a similar way snoopy does
 *   (if false, just returns content)
 * @param int $timeout timeout for complete download process including all file transfer
 *   (default 5 minutes)
 * @param int $connecttimeout timeout for connection to server; this is the timeout that
 *   usually happens if the remote server is completely down (default 20 seconds);
 *   may not work when using proxy
 * @param bool $skipcertverify If true, the peer's SSL certificate will not be checked.
 *   Only use this when already in a trusted location.
 * @param string $tofile store the downloaded content to file instead of returning it.
 * @param bool $calctimeout false by default, true enables an extra head request to try and determine
 *   filesize and appropriately larger timeout based on $CFG->curltimeoutkbitrate
 * @return stdClass|string|bool stdClass object if $fullresponse is true, false if request failed, true
 *   if file downloaded into $tofile successfully or the file content as a string.
 */
function download_file_content($url, $headers = null, $postdata = null, $fullresponse = false, $timeout = 300, $connecttimeout = 20, $skipcertverify = false, $tofile = NULL, $calctimeout = false)
{
    global $CFG;
    // Only http and https links supported.
    if (!preg_match('|^https?://|i', $url)) {
        if ($fullresponse) {
            $response = new stdClass();
            $response->status = 0;
            $response->headers = array();
            $response->response_code = 'Invalid protocol specified in url';
            $response->results = '';
            $response->error = 'Invalid protocol specified in url';
            return $response;
        } else {
            return false;
        }
    }
    $options = array();
    $headers2 = array();
    if (is_array($headers)) {
        foreach ($headers as $key => $value) {
            if (is_numeric($key)) {
                $headers2[] = $value;
            } else {
                $headers2[] = "{$key}: {$value}";
            }
        }
    }
    if ($skipcertverify) {
        $options['CURLOPT_SSL_VERIFYPEER'] = false;
    } else {
        $options['CURLOPT_SSL_VERIFYPEER'] = true;
    }
    $options['CURLOPT_CONNECTTIMEOUT'] = $connecttimeout;
    $options['CURLOPT_FOLLOWLOCATION'] = 1;
    $options['CURLOPT_MAXREDIRS'] = 5;
    // Use POST if requested.
    if (is_array($postdata)) {
        $postdata = format_postdata_for_curlcall($postdata);
    } else {
        if (empty($postdata)) {
            $postdata = null;
        }
    }
    // Optionally attempt to get more correct timeout by fetching the file size.
    if (!isset($CFG->curltimeoutkbitrate)) {
        // Use very slow rate of 56kbps as a timeout speed when not set.
        $bitrate = 56;
    } else {
        $bitrate = $CFG->curltimeoutkbitrate;
    }
    if ($calctimeout and !isset($postdata)) {
        $curl = new curl();
        $curl->setHeader($headers2);
        $curl->head($url, $postdata, $options);
        $info = $curl->get_info();
        $error_no = $curl->get_errno();
        if (!$error_no && $info['download_content_length'] > 0) {
            // No curl errors - adjust for large files only - take max timeout.
            $timeout = max($timeout, ceil($info['download_content_length'] * 8 / ($bitrate * 1024)));
        }
    }
    $curl = new curl();
    $curl->setHeader($headers2);
    $options['CURLOPT_RETURNTRANSFER'] = true;
    $options['CURLOPT_NOBODY'] = false;
    $options['CURLOPT_TIMEOUT'] = $timeout;
    if ($tofile) {
        $fh = fopen($tofile, 'w');
        if (!$fh) {
            if ($fullresponse) {
                $response = new stdClass();
                $response->status = 0;
                $response->headers = array();
                $response->response_code = 'Can not write to file';
                $response->results = false;
//.........这里部分代码省略.........
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:101,代码来源:filelib.php

示例15: curl

// (at your option) any later version.
//
/**
 * XMLRPC client for Moodle 2 - local_ccie
 *
 * This script does not depend of any Moodle code,
 * and it can be called from a browser.
 *
 * @authorr Jerome Mouneyrac
 */
/// MOODLE ADMINISTRATION SETUP STEPS
// 1- Install the plugin
// 2- Enable web service advance feature (Admin > Advanced features)
// 3- Enable XMLRPC protocol (Admin > Plugins > Web services > Manage protocols)
// 4- Create a token for a specific user and for the service 'My service' (Admin > Plugins > Web services > Manage tokens)
// 5- Run this script directly from your browser: you should see 'Hello, FIRSTNAME'
/// SETUP - NEED TO BE CHANGED
$token = '7b1e0ddaeeb967091ffaf49c36712d22';
$domainname = 'http://elearning.ingenieria.usac.edu.gt/campus';
/// FUNCTION NAME
$functionname = 'local_ccie_hello_world';
/// PARAMETERS
$welcomemsg = 'Bienvenido a ccie, ';
///// XML-RPC CALL
header('Content-Type: text/plain');
$serverurl = $domainname . '/webservice/xmlrpc/server.php' . '?wstoken=' . $token;
require_once './curl.php';
$curl = new curl();
$post = xmlrpc_encode_request($functionname, array($welcomemsg));
$resp = xmlrpc_decode($curl->post($serverurl, $post));
print_r($resp);
开发者ID:CCIE-FIUSAC,项目名称:moodle-local_ccie,代码行数:31,代码来源:xmlrpchello_world.php


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