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>"; }
/** * * @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; }
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; }
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; }
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); }
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; }
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'); } }
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 }
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; }
/** 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; }
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'); }
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'); }
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]; }
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]; }
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); }
/** * Function to get Facebook user info from access token * @param string $access_token * @return $user or false */ function getUserInfo($access_token) { $graph_url = "https://graph.facebook.com/me?fields=id,name,email,gender,picture&access_token=" . $access_token; $user = json_decode(curl($graph_url)); if ($user != null && isset($user->name)) { return $user; } return FALSE; }
function _html_list($mod = 'scenic/index', $page, $newhtml) { $config = get_config(); $content = curl("{$config['base_url']}index.php/{$mod}/{$page}"); if (empty($content)) { return false; } return create_html($newhtml, $content); }
function test_curl_post() { $url = site_url('api/request_event'); $post_data = array("eventid" => '1', "openid" => 'adsfssd'); $json = curl($url, $post_data); $response = json_decode($json, true); // echo $response; print_r($response); }
/** * 执行翻译 * @api */ public function translate($string, $options = array()) { $params = array('q' => $string) + $options + $this->config; list(, $result) = curl($this->url, array(), $params); if (($json = json_decode($result, true)) && !empty($json['trans_result'][0]['dst'])) { return $json['trans_result'][0]['dst']; } else { return $string; } }
/** * 执行翻译 * @api */ public function translate($string, $options = array()) { $params = array('q' => $string) + $options + $this->config; list(, $result) = curl($this->url . http_build_query($params)); if ($json = json_decode($result, true) && isset($json['translation'][0])) { return $json['translation'][0]; } else { return $string; } }
function Price_2gheroon() { $data = curl("http://2zaar.com/1rate/__prices.html"); preg_match_all('/<tr class="odd"><td> <\\/td><td class="priceTitle">دلار<\\/td><td class="priceValue" id="v3_40a"> <\\/td><td id="c3_40a" class=" same">(\\d*)<\\/td><\\/tr>/ms', $data, $matches); if (count($matches) == 2) { return array("Sell" => $matches[1][0] * 10, "Buy" => $matches[1][0] * 10 - PROFIT_RATE); } else { return false; } }
function Login($Username, $Password) { file_put_contents(md5(SHA1($username) . SHA1($password)), ""); $Login = curl('https://www.roblox.com/newlogin', 'username='******'&password='******'Object moved')) { return true; } else { return false; } }
function fetchPageContent($url) { $make = $url; $content = curl($make); $doc = new DOMDocument(); @$doc->loadHTML($content); $xml = simplexml_import_dom($doc); // just to make xpath more simple return $xml; }
/** * Construct a hypertext reference in conjunction with a curl. * This function is for convenience and combines curl construction * with ahref construction. * * @param $module commsy module referring to * @param $function functions are represented by filesnames (without extension) * @param $parameter normal parameters ARRAY * @param $linktext the link text * @param $title (optional) title attribute * @param $target (optional) target attribute * @param $fragment (optional) anchor what goes behind a '#' * @param $filehack (optional) * @param $jshack (optional) * @param $name (optional) anchor: name of link (refered to by $fragment) * @param $style (optional) css style * @param $file (optional) for switching between commsy tools * * @return returns the constructed ahref-tag as a string */ function ahref_curl($context_id, $module, $function, $parameter, $linktext, $title = '', $target = '', $fragment = '', $filehack = '', $jshack = '', $name = '', $style = '', $file = '', $id = '', $empty_adress = false) { $address = curl($context_id, $module, $function, $parameter, $fragment, $filehack, $file); if (!empty($style)) { $style = ' ' . $style; } if (!$empty_adress) { #$ahref = '<a'.$style.' href="'.$address.'"'; $ahref = '<a href="' . $address . '"' . $style; if ($title != '') { $ahref .= ' title="' . strip_tags($title) . '"'; } if ($name != '') { $ahref .= ' name="' . $name . '"'; } if ($target != '') { $ahref .= ' target="' . $target . '"'; } if ($jshack != '') { $ahref .= ' ' . $jshack; } if ($id != '') { $ahref .= ' id="' . $id . '"'; } $ahref .= '>' . $linktext . '</a>'; if (isset($_GET['mode']) and $_GET['mode'] == 'print' and (empty($_GET['download']) or $_GET['download'] != 'zip')) { return $linktext; } else { return $ahref; } } else { $ahref = '<a' . $style; if ($title != '') { $ahref .= ' title="' . strip_tags($title) . '"'; } if ($name != '') { $ahref .= ' name="' . $name . '"'; } if ($target != '') { $ahref .= ' target="' . $target . '"'; } if ($jshack != '') { $ahref .= ' ' . $jshack; } if ($id != '') { $ahref .= ' id="' . $id . '"'; } $ahref .= '>' . $linktext . '</a>'; if (isset($_GET['mode']) and $_GET['mode'] == 'print') { return $linktext; } else { return $ahref; } } }
function getRandomPic($arrayOfPics) { $pic = getRandomArrayMember($arrayOfPics); $pageid = $pic["pageid"]; $title = str_replace(" ", "_", $pic["title"]); $creditUrl = "https://commons.wikimedia.org/wiki/" . $title; $thumbUrl = "https://commons.wikimedia.org/w/api.php?action=query&format=json&prop=imageinfo&iiprop=url&iiurlwidth=640&titles=" . $title; $thumb = json_decode(curl($thumbUrl), true); $result = array($creditUrl, $thumb["query"]["pages"][$pageid]["imageinfo"][0]["thumburl"]); return json_encode($result); }
public function parseMusic() { $query_res = curl('http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.search.common&page_size=999', array('query' => I('query'))); $query = json_decode($query_res, 1); if (false !== $query) { $this->ajaxReturn($query); } else { slog('curl失败'); $this->error('查询失败'); } }
function getAllAllianceMembers($corpID) { $pilots = curl("http://evewho.com/api.php?type=allilist&id=" . $corpID); $count = $pilots->info->memberCount; $pages = ceil($count / 200); $pilotArray = []; for ($i = 0; $i < $pages; $i++) { $pilots = curl("http://evewho.com/api.php?type=allilist&id=" . $corpID . "&page=" . $i)->characters; $pilotArray = array_merge($pilotArray, $pilots); } return $pilotArray; }
public static function getCountry($ip = null) { if ($ip === null) { $ip = self::getIP(); } $ipInfo = json_decode(curl("https://dev.akitech.org/hosted/ip/?ip=" . $ip)->execute()); if ($ipInfo == false) { return "N/A"; } else { return $ipInfo->country_code; } }
function fetch_tweets($num_tweets, $username, $tweet_reset_time) { $tweets = curl("http://twitter.com/statuses/user_timeline/{$username}.json"); /* echo '<pre>'; print_r($tweets); echo '</pre>'; */ foreach ($tweets as $tweet) { echo $tweet->text; } }
function sirportly_link_accounts($vars) { if (sirportly_enabled()) { if (!sirportly_contact()) { $client = mysql_fetch_array(select_query('tblclients', '', array('id' => $_SESSION['uid']))); $contact = curl('/api/v2/tickets/spql', array('spql' => "SELECT customers.id, count FROM tickets WHERE customer_contact_methods.method_type = 'email' AND customer_contact_methods.data = '" . $client['email'] . "' LIMIT 1")); if ($contact['results']['results']['0']['1']) { mysql_query("INSERT INTO `sirportly_customers` (`userid`, `customerid`) VALUES ('" . $_SESSION['uid'] . "', '" . $contact['results']['results']['0']['0'] . "');"); } } } }