/** * Init CLDR data and download default language */ public function init() { if (!is_file($file = $this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'core.zip')) { $fp = fopen($file, "w"); $curl = new Curl(); $curl->setopt(CURLOPT_FILE, $fp); $curl->setopt(CURLOPT_FOLLOWLOCATION, true); $curl->setopt(CURLOPT_HEADER, false); $curl->get(self::ZIP_CORE_URL); if ($curl->error) { throw new \Exception("Failed to download '" . self::ZIP_CORE_URL . "'."); } fclose($fp); } //extract ONLY supplemental json files $archive = new \ZipArchive(); if ($archive->open($file) === true) { for ($i = 0; $i < $archive->numFiles; $i++) { $filename = $archive->getNameIndex($i); if (preg_match('%^supplemental\\/(.*).json$%', $filename)) { if (!is_dir($this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . dirname($filename))) { mkdir($this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . dirname($filename), 0777, true); } if (!file_exists($this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . $filename)) { copy("zip://" . $file . "#" . $filename, $this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . $filename); $this->newDatasFile[] = $this->cldrCacheFolder . DIRECTORY_SEPARATOR . 'datas' . DIRECTORY_SEPARATOR . $filename; } } } $archive->close(); } else { throw new \Exception("Failed to unzip '" . $file . "'."); } $this->generateSupplementalDatas(); }
public function update($c_id, $fname = '', $mname = '', $lname = '', $gen = '', $avatar = '', $addl1 = '', $addl2 = '', $city = '', $state = '', $country = '', $zip = '', $dob = '') { $curl = new Curl(); $curl->setopt(CURLOPT_URL, "https://v2.api.xapo.com/customers/{$c_id}/?first_name={$fname}middle_name={$mname}&last_name={$lname}&gender={$gen}&avatar={$avatar}&address_line_1={$addl1}&address_line_2={$addl2}&city={$city}&state={$state}&country_iso3={$country}&zip_code={$zip}&date_of_birth={$dob}"); $curl->setopt(CURLOPT_RETURNTRANSFER, true); $curl->setopt(CURLOPT_HEADER, false); $curl->setopt(CURLOPT_CUSTOMREQUEST, 'PATCH'); $curl->_exec(); $response = $curl->response; $curl->close(); return json_decode($response); }
public function prim_address($token, $acc_id) { $curl = new Curl(); $curl->setopt(CURLOPT_URL, "https://v2.api.xapo.com/accounts/{$acc_id}/primary_address/"); $curl->setopt(CURLOPT_RETURNTRANSFER, true); $curl->setopt(CURLOPT_HEADER, false); $curl->setopt(CURLOPT_HTTPHEADER, ["Authorization: Bearer {$token}"]); $curl->_exec(); $curl->close(); $response = $curl->response; return json_decode($response); }
public function disable($token, $id) { $curl = new Curl(); $curl->setopt(CURLOPT_URL, "https://v2.api.xapo.com/webhooks/{$id}/disable"); $curl->setopt(CURLOPT_RETURNTRANSFER, true); $curl->setopt(CURLOPT_HEADER, false); $curl->setopt(CURLOPT_POST, true); $curl->setopt(CURLOPT_HTTPHEADER, ["Authorization: Bearer {$token}"]); $curl->_exec(); $response = $curl->response; $curl->close(); return $response; }
/** * Send SMS from specified account * * @param string $recipient : recipient mobile number * @param string $message : message to be sent * @param string $mode : account to send the SMS from * @param string $format : content type * @return string containing cURL response */ public function send($recipient, $message, $mode = '', $format = '') { /* make sure credit is available before proceed */ $balance = $this->balance(empty($mode) ? $this->mode : $mode); if ($balance == 0) { return false; } $curl = new Curl\Curl(); $curl->setopt(CURLOPT_RETURNTRANSFER, true); $curl->get($this->url . 'index.php/api/bulk_mt', array('api_key' => $this->token, 'action' => 'send', 'to' => $recipient, 'msg' => $message, 'sender_id' => $this->sender, 'content_type' => empty($format) ? $this->format : $format, 'mode' => empty($mode) ? $this->mode : $mode)); $curl->close(); if ($curl->error) { return false; } else { return $curl->response; } }
public function scrape($locale = 'en-us', $user_agent = false, $proxy = false) { $curl = new Curl(); $curl->setHeader('Accept-Language', $locale); $curl->setopt(CURLOPT_SSL_VERIFYPEER, FALSE); if ($user_agent) { $curl->setOpt(CURLOPT_USERAGENT, $user_agent); } if ($proxy) { $curl->setOpt(CURLOPT_PROXY, $proxy); // $curl->setOpt(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); } $curl->get($this->trends_url); if ($curl->error) { throw new FailedRetrieveTrendsException('Error #' . $curl->error_code . ': ' . $curl->error_message); } $this->parseTrendsFromResponse($curl->response); }
public function new($redirect_uri) { $curl = new Curl(); $curl->setopt(CURLOPT_RETURNTRANSFER, true); $curl->setopt(CURLOPT_HEADER, false); $curl->setopt(CURLOPT_URL, 'https://v2.api.xapo.com/oauth2/token'); $curl->setopt(CURLOPT_POST, true); $curl->setopt(CURLOPT_POSTFIELDS, "grant_type=client_credentials&redirect_uri={$redirect_uri}"); $curl->setopt(CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded', "Authorization: Basic {$this->hash}"]); $curl->_exec(); $curl->close(); return json_decode($curl->response)->access_token; }
public function update($token, $addr, $amount) { $curl = new Curl(); $curl->setopt(CURLOPT_URL, "https://v2.api.xapo.com/addresses/{$addr}?payment_threshold={$amount}"); $curl->setopt(CURLOPT_RETURNTRANSFER, true); $curl->setopt(CURLOPT_HEADER, false); $curl->setopt(CURLOPT_CUSTOMREQUEST, 'PATCH'); $curl->setopt(CURLOPT_POSTFIELDS, ['payment_threshold' => $amount]); $curl->setopt(CURLOPT_HTTPHEADER, ["Authorization: Bearer {$token}"]); $curl->_exec(); $response = $curl->response; $curl->close(); return json_decode($response); }
public function curl_post($sUrl, $aPOSTParam, $timeout = 5) { $curl = new Curl(); if ($timeout) { $curl->setopt(CURLOPT_CONNECTTIMEOUT, $timeout); } $curl->post($sUrl, $aPOSTParam); $curl->close(); return $curl->error ? false : $curl->response; }
<?php require '../../vendor/autoload.php'; use Curl\Curl; $cookiefile = tempnam("/tmp", "cookies"); $user_agent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1'; $curl = new Curl(); $curl->setUserAgent($user_agent); $curl->setOpt(CURLOPT_HEADER, 0); $curl->setopt(CURLOPT_RETURNTRANSFER, TRUE); $curl->setopt(CURLOPT_FOLLOWLOCATION, TRUE); $curl->setopt(CURLOPT_SSL_VERIFYPEER, FALSE); $curl->setopt(CURLOPT_SSL_VERIFYHOST, FALSE); $curl->setopt(CURLOPT_COOKIEFILE, $cookiefile); $curl->setopt(CURLOPT_COOKIEJAR, $cookiefile); $get = $curl->get('google.com'); var_dump($curl);
require __DIR__ . '/vendor/autoload.php'; use Curl\Curl; $downloadBaseUrl = "http://163.17.39.135/data/school/board/"; $sfs3BoardUrl = "http://163.17.39.135/modules/json/jsonBoard/index.php"; $myLog = "download/ajax.log"; //file_put_contents($wFile,($_GET)); $obj = json_decode(urldecode(implode('', $_GET))); //$obj->{'articleId'} //$obj->{'page'} if (isset($obj->{'page'})) { $page = $obj->{'page'}; } else { $page = 0; } $curl = new Curl(); $curl->setopt(CURLOPT_RETURNTRANSFER, TRUE); $curl->setopt(CURLOPT_SSL_VERIFYPEER, FALSE); $curl->get($sfs3BoardUrl, array('page' => $page)); if ($curl->error) { echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage; } else { if (isset($obj->{'articleId'})) { //file_put_contents($myLog,($obj->{'articleId'})); //$jsonFile = sprintf("json/board%d.json",$obj->{'page'}); //$jsonObj = json_decode(file_get_contents($jsonFile)); $jsonObj = json_decode($curl->response); //file_put_contents($myLog,$jsonObj); $downloadFiles = array(); $i = 0; foreach ($jsonObj->records as $article) { //print $article->articleId ;