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


PHP Curl::simple_get方法代码示例

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


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

示例1: execute

 public static function execute($params)
 {
     $curl = new Curl();
     $url = 'http://reseller.enom.com/interface.asp';
     $options = array();
     foreach ($params as $key => $param) {
         $option = "{$key}={$param}";
         array_push($options, $option);
     }
     $myOptions = implode('&', $options);
     $req = $url . '?' . $myOptions;
     $output = $curl->simple_get($req);
     $xml = simplexml_load_string($output);
     $json = json_encode($xml);
     $array = json_decode($json, TRUE);
     return $array;
 }
开发者ID:jasimmk,项目名称:DeveloperSupport,代码行数:17,代码来源:enom_wrapper.php

示例2: curlData

 /**
  * Curl data
  *
  * @return void
  * @author apple
  **/
 function curlData($url, $params = array(), $type = 'GET', $debug = 0, $options = array())
 {
     $cl = new Curl();
     if ($type == 'GET') {
         $params = $params ? '?' . MY_paraseGetArray($params) : "";
         $curl['url'] = site_url($url . $params);
         $json = $cl->simple_get($curl['url'], $options);
     } else {
         $curl['url'] = site_url($url);
         $json = $cl->simple_post($curl['url'], $params, $options);
     }
     if ($debug) {
         $cl->debug();
     }
     // debug
     $json = json_decode($json, TRUE);
     return $json;
 }
开发者ID:Demired,项目名称:CakeWX,代码行数:24,代码来源:func.php

示例3: get_stop_by_time

 /**
  * @param $sid: stop_id defined by railtime
  * @param $sn: according to $sid
  * @param $time: time in ISO 8601
  * @param $da: enum('D','A') (Departure / Arrival)
  *
  * involves one single curl request
  * usually invoked by get_stop($sid,$date)
  */
 private function get_stop_by_time($sid, $sn, $time, $da)
 {
     if ($da != 'D' && $da != 'A') {
         return FALSE;
     }
     $url = 'http://www.railtime.be/mobile/HTML/StationDetail.aspx';
     $dt = Date('d/m/Y', strtotime($time));
     $ti = Date('H:i', strtotime($time));
     /* add parameters */
     $params = array();
     $params['l'] = 'NL';
     $params['sid'] = $sid;
     // station id
     $params['sn'] = $sn;
     // station name
     $params['dt'] = $dt;
     // date
     $params['ti'] = $ti;
     // time
     $params['da'] = $da;
     // enum('D','A') departure or arrival
     /* build url & get data */
     $url .= '?' . http_build_query($params);
     $curl = new \Curl();
     $result = $curl->simple_get($url);
     if (!is_null($curl->error_code)) {
         $curl->setDefaults();
         return FALSE;
     }
     $time_match = array();
     preg_match_all('/\\(\\d\\d:\\d\\d\\ -\\ (\\d\\d:\\d\\d)\\)/si', $result, $time_match);
     if (!isset($time_match[1][0])) {
         return ['end_time' => '01:30', 'service_stops' => array()];
     }
     $end_time = $time_match[1][0];
     /* parse data */
     $matches1 = array();
     preg_match_all('/\\<tr\\ class.+?\\>(.+?)\\<\\/tr\\>/si', $result, $matches1);
     $service_stops = array();
     foreach (@end($matches1) as $vehicle) {
         $v = array();
         /* do some parsing */
         $matches2 = array();
         preg_match_all('/\\<label.*?\\>(.*?)\\<\\/label\\>/si', $vehicle, $matches2);
         $matches3 = array();
         preg_match_all('/&amp;tid=(\\d+)&amp;/si', $vehicle, $matches3);
         /* fill in the variables */
         $vars = @$matches2[1];
         $tid = reset(@end($matches3));
         list($hour, $minutes) = explode(':', $vars[0]);
         $planned = Date('c', mktime(intval($hour), intval($minutes), 0, date('m', strtotime($time)), date('d', strtotime($time)), date('Y', strtotime($time))));
         $v['type'] = substr($vars[3], 1, -1);
         $v['headsign'] = html_entity_decode($vars[2], ENT_HTML5, "UTF-8");
         if (!preg_match('/\\*\\*\\*/', $vars[5])) {
             $v['platform'] = trim($vars[5]);
         }
         /* Don't drop this data because it is used for displaying 
            an entry at the right spot even if the vehicle is cancelled */
         if ($da == 'D') {
             $v['departure_time'] = date('c', strtotime($planned));
         } else {
             $v['arrival_time'] = date('c', strtotime($planned));
         }
         $v['tid'] = $tid;
         $v['sid'] = $sid;
         $v['agency'] = 'NMBS-SNCB';
         $v['date'] = date('Ymd', strtotime($time));
         $service_stops[$tid] = $v;
     }
     return ['end_time' => $end_time, 'service_stops' => $service_stops];
 }
开发者ID:hannesvdvreken,项目名称:railtime-scraper,代码行数:80,代码来源:RailTimeScraper.php

示例4: refresh_map_tile

function refresh_map_tile($x, $y, $regionImage)
{
    $success = false;
    $curl = new Curl();
    $maptile = $curl->simple_get($regionImage);
    if ($maptile) {
        if (!add_map_tile($x, $y, $maptile)) {
            log_message('warn', "Unable to upload map image from {$regionImage}");
        } else {
            $success = true;
        }
    } else {
        log_message('warn', "unable to fetch map image from {$regionImage}");
    }
    return $success;
}
开发者ID:QuillLittlefeather,项目名称:mgm-simiangrid,代码行数:16,代码来源:SimianGrid.php

示例5: postLicenseManager

 /**
  * License Manager
  *
  * Allows to check plans and activate a license key
  */
 public function postLicenseManager($method = NULL)
 {
     // Include libraries
     require_once app_path() . "/libraries/Curl/Curl.php";
     // Validate the request
     if ($this->_isValidRequest()) {
         $code = Input::get('code') ? Input::get('code') : Input::get('amp;code');
         $license_key = Input::get('license');
         $guid = Input::get('guid') ? Input::get('guid') : Input::get('amp;guid');
         if (!$code or !$license_key) {
             $this->_invalidRequest("Code and License Key parameters are required");
         }
         // Get product code and then fetch secret key
         $product = Product::where('code', '=', $code)->first();
         if (!$product) {
             $this->_invalidRequest("Product was not found, contact support.");
         }
         // Get License Data
         $license = License::where("license_key", "=", $license_key)->first();
         if (!$license) {
             $this->_invalidRequest("License Key was not found");
         }
         // Get all active plans of a buyer
         if (!$method) {
             $transaction = Transaction::where("id", "=", $license->transaction_id)->first();
             $buyer_email = $transaction->purchase->buyer->email;
             $curl = new Curl();
             $plans = $curl->simple_get($product->api_url, array("getPlans" => $buyer_email), array(CURLOPT_BUFFERSIZE => 10));
             $plans = json_decode($plans);
             if ($plans) {
                 $plans->created_at = $license->created_at;
                 die(json_encode($plans));
             } else {
                 die(json_encode(array()));
             }
         }
         // Activate license key for a GUID
         if ($method == "activate") {
             // Check if License is already activated
             if (!$guid) {
                 $this->_invalidRequest("GUID parameter is required");
             }
             // Total Licenses Used
             $totalLicensesUsed = LicensesUses::where("license_id", "=", $license->id)->count();
             if (!$license->status) {
                 $response = array("success" => "false", "overusage" => "false");
             } else {
                 // If user has allowed usage
                 if ($totalLicensesUsed >= $license->allowed_usage) {
                     $response = array("success" => "false", "overusage" => "true");
                 } else {
                     $licensesUses = LicensesUses::where("license_id", "=", $license->id)->where("guid", "=", $guid)->first();
                     if ($licensesUses) {
                         // Update last checked
                         $licensesUses->last_checked = time();
                         $licensesUses->save();
                     } else {
                         // Add to DB
                         $licensesUses = new LicensesUses();
                         $licensesUses->license_id = $license->id;
                         $licensesUses->guid = $guid;
                         $licensesUses->activated_at = time();
                         $licensesUses->last_checked = time();
                         $licensesUses->save();
                     }
                     $response = array("success" => "true", "overusage" => "false");
                 }
             }
             die(json_encode($response));
         }
     }
 }
开发者ID:michaelotto126,项目名称:dksolution,代码行数:77,代码来源:ApiController.php

示例6: postPaypalOto

 /**
  * Post OTO for paypal
  */
 public function postPaypalOto()
 {
     $product_id = Input::get('product_id');
     $plan_id = Input::get('plan_id');
     $buyer_id = Input::get('buyer_id');
     $product = Product::where('id', '=', $product_id)->first();
     $plan = Plan::where('id', '=', $plan_id)->first();
     $buyer = Buyer::where('id', '=', $buyer_id)->first();
     // $plan->price $plan->name  $plan->id
     // PayPal SetExpressCheckout
     $config = array('mode' => Config::get('project.paypal_mode'), 'acct1.UserName' => Config::get('project.paypal_api_username'), 'acct1.Password' => Config::get('project.paypal_api_password'), 'acct1.Signature' => Config::get('project.paypal_api_signature'));
     /*
      * The SetExpressCheckout API operation initiates an Express Checkout transaction
      * This sample code uses Merchant PHP SDK to make API call
      */
     $returnUrl = url("checkout/paypal-confirm-oto");
     //"http://secure.digitalkickstart.com/checkout/paypal-confirm-oto";
     $cancelUrl = url("checkout/paypal-cancel");
     //"http://secure.digitalkickstart.com/checkout/paypal-cancel";
     $currencyCode = 'USD';
     $orderTotal = $plan->price + $plan->setup_fee;
     // If recurring then process manually without PayPal Merchant SDK
     if ($plan->is_recurring) {
         // For Recurring
         $ecRequestParams = array('USER' => Config::get('project.paypal_api_username'), 'PWD' => Config::get('project.paypal_api_password'), 'SIGNATURE' => Config::get('project.paypal_api_signature'), 'VERSION' => '109.0', 'METHOD' => 'SetExpressCheckout', 'RETURNURL' => $returnUrl, 'CANCELURL' => $cancelUrl, 'PAYMENTREQUEST_0_AMT' => $orderTotal, 'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD', 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', 'REQCONFIRMSHIPPING' => 0, 'NOSHIPPING' => 1, 'PROFILESTARTDATE' => date(DATE_ATOM, time() + 86400 * 30 * $plan->recurring_freq), 'L_BILLINGTYPE0' => 'RecurringPayments', 'L_BILLINGAGREEMENTDESCRIPTION0' => $product->name . " - " . $plan->name, 'PAYMENTREQUEST_0_CUSTOM' => 'RecurringPayment');
         $ecRequestParams = http_build_query($ecRequestParams);
         $curl = new Curl();
         $api_url = "https://api-3t.paypal.com/nvp?";
         if (Config::get('project.paypal_mode') == 'sandbox') {
             $api_url = "https://api-3t.sandbox.paypal.com/nvp?";
         }
         $api_url = $api_url . $ecRequestParams;
         $curl->ssl(false);
         $response = $curl->simple_get($api_url);
         $data = array();
         $key = explode('&', $response);
         if (is_array($key)) {
             foreach ($key as $temp) {
                 $keyval = explode('=', $temp);
                 if (isset($keyval[1])) {
                     $data[$keyval[0]] = $keyval[1];
                 }
             }
         }
         if (!empty($data['TOKEN'])) {
             $token = $data['TOKEN'];
             $payPalURL = Config::get('project.paypal_api_url') . "webscr?cmd=_express-checkout&token={$token}&useraction=commit";
             // Store Data in session
             Session::put('_product', $product_id);
             Session::put('_plan', $plan_id);
             Session::put('_buyer', $buyer_id);
             return Response::make(json_encode(array("success" => true, "url" => $payPalURL)));
         }
         Session::flash('error', "Payment processing error");
         return json_encode(array("error" => true, "message" => "Payment processing error"));
     }
     // details about payment
     $paymentDetails = new PayPal\EBLBaseComponents\PaymentDetailsType();
     // total order amount
     $paymentDetails->OrderTotal = new PayPal\CoreComponentTypes\BasicAmountType($currencyCode, $orderTotal);
     $paymentDetails->PaymentAction = 'Sale';
     $paymentDetails->Custom = $plan->id;
     $paymentDetails->OrderDescription = $product->name . " - " . $plan->name;
     $itemDetails = new PayPal\EBLBaseComponents\PaymentDetailsItemType();
     $itemDetails->Name = $product->name . " - " . $plan->name;
     $itemDetails->Amount = $orderTotal;
     $paymentDetails->PaymentDetailsItem[0] = $itemDetails;
     $setECReqDetails = new PayPal\EBLBaseComponents\SetExpressCheckoutRequestDetailsType();
     $setECReqDetails->PaymentDetails[0] = $paymentDetails;
     /*
      * (Required) URL to which the buyer is returned if the buyer does not approve the use of PayPal to pay you. For digital goods, you must add JavaScript to this page to close the in-context experience.
      */
     $setECReqDetails->CancelURL = $cancelUrl;
     /*
      * (Required) URL to which the buyer's browser is returned after choosing to pay with PayPal. For digital goods, you must add JavaScript to this page to close the in-context experience.
      */
     $setECReqDetails->ReturnURL = $returnUrl;
     $setECReqDetails->NoShipping = TRUE;
     $setECReqType = new PayPal\PayPalAPI\SetExpressCheckoutRequestType();
     $setECReqType->SetExpressCheckoutRequestDetails = $setECReqDetails;
     $setECReq = new PayPal\PayPalAPI\SetExpressCheckoutReq();
     $setECReq->SetExpressCheckoutRequest = $setECReqType;
     $paypalService = new PayPal\Service\PayPalAPIInterfaceServiceService($config);
     try {
         /* wrap API method calls on the service object with a try catch */
         $setECResponse = $paypalService->SetExpressCheckout($setECReq);
     } catch (Exception $ex) {
         return Response::make(json_encode(array("error" => true, "message" => "Payment processing error")));
     }
     if (isset($setECResponse)) {
         if ($setECResponse->Ack == 'Success') {
             $token = $setECResponse->Token;
             // Redirect to paypal.com here
             $payPalURL = Config::get('project.paypal_api_url') . "webscr?cmd=_express-checkout&token={$token}&useraction=commit";
             // Store Data in session
             Session::put('_product', $product_id);
             Session::put('_plan', $plan_id);
//.........这里部分代码省略.........
开发者ID:michaelotto126,项目名称:dksolution,代码行数:101,代码来源:CheckoutController.php


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