本文整理汇总了PHP中file_get_contents_curl函数的典型用法代码示例。如果您正苦于以下问题:PHP file_get_contents_curl函数的具体用法?PHP file_get_contents_curl怎么用?PHP file_get_contents_curl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_get_contents_curl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: worksheetsToArray
function worksheetsToArray($id)
{
$entries = array();
$i = 1;
while (true) {
$url = 'https://spreadsheets.google.com/feeds/list/' . $id . '/' . $i . '/public/full?alt=json';
$data = @json_decode(file_get_contents_curl($url), true);
$starttag = substr($data['feed']['title']["\$t"], 0, strpos($data['feed']['title']["\$t"], " "));
if (!isset($data['feed']['entry'])) {
break;
}
foreach ($data['feed']['entry'] as $entryKey => $entry) {
$data['feed']['entry'][$entryKey]['gsx$starttag']["\$t"] = $starttag;
}
$entries = array_merge($entries, $data['feed']['entry']);
$i++;
}
return $entries;
}
示例2: html_no_comment
function html_no_comment($url)
{
$url = _urlencode($url);
// create HTML DOM
$check_curl = _isCurl();
if (!($html = file_get_html($url))) {
if (!($html = str_get_html(file_get_contents_curl($url))) or !$check_curl) {
return false;
}
}
// remove all comment elements
foreach ($html->find('comment') as $e) {
$e->outertext = '';
}
$ret = $html->save();
// clean up memory
$html->clear();
unset($html);
return $ret;
}
示例3: getSteamNames
function getSteamNames($steamID)
{
$steamUserNamesUrl = file_get_contents_curl("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=41AF33A7F00028D1E153D748597DEEF3&steamids=" . $steamID);
$content = json_decode($steamUserNamesUrl, true);
$pieces = explode(",%20", $steamID);
if (count($pieces) > 99) {
for ($x = 100; $x <= count($pieces) - 2; $x++) {
if ($x >= count($pieces) - 2) {
$steamfriendsExtended .= $pieces[$x];
} else {
$steamfriendsExtended .= $pieces[$x] . ',%20';
}
}
$steamfriendsExtendedUrl = file_get_contents_curl("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=41AF33A7F00028D1E153D748597DEEF3&steamids=" . $steamfriendsExtended);
$steamfriendsExtendedContent = json_decode($steamfriendsExtendedUrl, true);
foreach ($steamfriendsExtendedContent['response']['players'] as $player) {
array_push($content['response']['players'], $player);
}
}
return $content['response']['players'];
}
示例4: instagram_get_photos
function instagram_get_photos($username, $num = 5)
{
//look for user id
$requser = "https://api.instagram.com/v1/users/search?q=" . $username . "&client_id=" . INSTAGRAM_KEY;
$res = file_get_contents_curl($requser);
$user_data = json_decode($res);
$user_id = 0;
//print_r($user_data);
foreach ($user_data->data as $user) {
if ($user->username == $username) {
$user_id = $user->id;
break;
}
}
if ($user_id == 0) {
return false;
}
//and now get the pictures
$uri = "https://api.instagram.com/v1/users/" . $user_id . "/media/recent?count=" . $num . "&client_id=" . INSTAGRAM_KEY;
$res = file_get_contents_curl($uri);
$content = json_decode($res);
return $content;
}
示例5: fn_sb_movie_infobox_cache
function fn_sb_movie_infobox_cache($id, $detailType)
{
// $cacheage = get_option('imdbcacheage', -1);
$cacheage = -1;
$imageCacheDir = SB_CACHE_DIR . "/" . $id . ".jpg";
$imageCacheUrl = SB_CACHE_URL . "/" . $id . ".jpg";
$jsonCacheDir = SB_CACHE_DIR . "/" . $id . ".json";
if (!file_exists($imageCacheDir) || $cacheage > -1 && filemtime($imageCacheDir) < time() - $cacheage || !file_exists($jsonCacheDir) || $cacheage > -1 && filemtime($jsonCacheDir) < time() - $cacheage) {
//$url = "http://www.omdbapi.com/?i=".$movieid."&plot=short&r=json";
$url = "http://www.omdbapi.com/?i={$id}&plot={$detailType}&r=json";
$http_args = array('user-agent' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)');
$rawResponse = wp_remote_request($url, $http_args);
$rawResponse = $rawResponse['body'];
// $raw = file_get_contents_curl('http://www.omdbapi.com/?i=' . $id."&plot=short&r=json");
$json = json_decode($rawResponse, true);
$jsonResult = file_put_contents($jsonCacheDir, $rawResponse);
// echo("jsonResult". $jsonResult . "<br/>");
$img = file_get_contents_curl($json['Poster']);
$jsonResult = file_put_contents($imageCacheDir, $img);
$json['Poster'] = $imageCacheUrl;
} else {
$rawResponse = file_get_contents($jsonCacheDir);
$json = json_decode($rawResponse, true);
$json['Poster'] = $imageCacheUrl;
}
return $json;
}
示例6: method
/**
* Делает запрос к Api VK
* @param $method
* @param $params
*/
public function method($method, $params = null)
{
$p = "";
if ($params && is_array($params)) {
foreach ($params as $key => $param) {
$p .= ($p == "" ? "" : "&") . $key . "=" . urlencode($param);
}
}
/* $response = file_get_contents($this->url . $method . "?" . ($p ? $p . "&" : "") . "access_token=" . $this->access_token);
if( $response ) {
return json_decode($response);
}
return false;
} */
function file_get_contents_curl($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, True);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Устанавливаем параметр, чтобы curl возвращал данные, вместо того, чтобы выводить их в браузер.
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$response = file_get_contents_curl($this->url . $method . "?" . ($p ? $p . "&" : "") . "access_token=" . $this->access_token);
if ($response) {
return json_decode($response);
}
return false;
}
示例7: _request
private function _request($request)
{
$request = array_map('Comet_encode', $request);
array_unshift($request, $this->ORIGIN);
$ctx = stream_context_create(array('http' => array('timeout' => 200)));
return json_decode(file_get_contents_curl(implode('/', $request)), true);
}
示例8: buildCSV
function buildCSV()
{
$html = file_get_contents_curl(FACULTY_WEB);
$matches;
$table_regex = '/<td[^>]*>(.*?)<\\/td>/';
preg_match_all($table_regex, $html, $matches);
$clean = array();
$email = "";
$name = "";
$department = "";
for ($i = 3; $i < count($matches[0]); $i++) {
$text = strip_tags($matches[0][$i]);
if ($i % 3 == 0) {
$text = preg_replace('(\\(.*\\))', '', $text);
$text = firstlast($text);
$text = str_replace(",", "", $text);
$name = $text;
}
if ($i % 3 == 1) {
$text = preg_replace('(\\(.*\\))', '', $text);
$text = str_replace(",", "", $text);
$department = $text;
}
if ($i % 3 == 2) {
$text = str_replace("*", "@uwo.ca", $text);
$email = $text;
array_push($clean, $email, $name, $department);
}
}
$final = "";
for ($i = 0; $i < count($clean); $i++) {
$final .= "\"" . $clean[$i++] . "\", \"" . $clean[$i++] . "\", \"" . $clean[$i] . "\"\n";
}
file_put_contents(FACULTY_FILE, $final);
}
示例9: cache_image
function cache_image($imageurl = '', $name)
{
$imagename = $name . '.' . get_image_extension($imageurl);
if (file_exists('./tmp/' . $imagename)) {
return 'tmp/' . $imagename;
}
$image = file_get_contents_curl($imageurl);
file_put_contents('tmp/' . $imagename, $image);
return 'tmp/' . $imagename;
}
示例10: login
function login( $uacc, $upwd ){
$login = (array)json_decode(
file_get_contents_curl(
'http://apit.cedric.testapi-1.stu.edu.tw/acc/auth/uacc/'.$uacc.'/?upwd='.$upwd),true);
# Authentication fail.
if ( $login['status'] )
print_response_msg(3);
# Analyze data.
$ou_group;
$start_tag = "ou=";
$close_tag = ",";
preg_match_all("($start_tag(.*)$close_tag)siU", $login['dn'], $ou_group);
# If login user not is student, this column value set 0.
if ( !preg_match('/\d{2,3}/', $ou_group[1][0]) )
$ou_group[1][0] = 0;
# Get record data.
$sql = "SELECT record_id FROM record WHERE account=? ";
$record_id = sql_q( $sql, array($login['uacc']) );
# If this account not have play record in database, insert new row to database.
if ( !count($record_id) ) {
$addRecord = add_record(
$login['uacc'],
$ou_group[1][1]
);
if ( $addRecord )
$record_id = sql_q( $sql, array($login['uacc']) );
else
print_response_msg(5);
}
# Session content
$profile = array(
'record_id' => $record_id[0]['record_id'],
'account' => $login['uacc'],
'name' => $login['uname'],
'dep' => $ou_group[1][1]
);
# Define session
$_SESSION[ session_id() ] = $profile;
# Print login success message and session data.
print_response_msg( 2, $profile );
}
示例11: power_ga_mp
function power_ga_mp($keyword, $title = '(unknown)', $referer = '')
{
$version = 1;
$z = rand(100000000000, 999999999999);
// Cache Buster to ensure browsers and proxies don't cache hits
$power_ga_mp_GAID = 'UA-33563207-5';
$data = array('v' => $version, 'tid' => $power_ga_mp_GAID, 'cid' => power_ga_mp_gaParseCookie(), 'uip' => $_SERVER['REMOTE_ADDR'], 'z' => $z, 't' => 'pageview', 'dh' => $_SERVER['SERVER_NAME'], 'dp' => $keyword, 'dt' => $title, 'dr' => $referer);
if ($data) {
$getString = 'https://ssl.google-analytics.com/collect';
$getString .= '?payload_data&';
$getString .= http_build_query($data);
$result = file_get_contents_curl($getString);
return $result;
}
return false;
}
示例12: get_facebook_id
function get_facebook_id($url)
{
$html = file_get_contents_curl($url);
//parsing begins here:
$doc = new DOMDocument();
@$doc->loadHTML($html);
$metas = $doc->getElementsByTagName('meta');
for ($i = 0; $i < $metas->length; $i++) {
$meta = $metas->item($i);
if ($meta->getAttribute('name') == 'description') {
$description = $meta->getAttribute('content');
}
if ($meta->getAttribute('property') == 'al:android:url') {
preg_match('!\\d+!', $meta->getAttribute('content'), $fbid);
}
}
return $fbid;
}
示例13: fetch_image_post
public static function fetch_image_post($post_id = '', $link = '', $comment_fbid = '')
{
if (!$post_id || !$link) {
return;
}
$image = '';
if ($comment_fbid) {
$app_id = FB_APP_ID;
$app_secret = FB_SECRET;
$url = "https://graph.facebook.com/{$comment_fbid}?access_token={$app_id}|{$app_secret}";
$obj = json_decode(file_get_contents_curl($url));
if (isset($obj->image) && $obj->image) {
$image = $obj->image->url;
}
}
var_dump($image);
die;
if (!empty($image)) {
$graph = OpenGraph::fetch($link);
var_dump($graph);
die;
}
}
示例14: grabSkyScanner
public function grabSkyScanner($urls)
{
$folder = 'console.data_files.skyscanner';
$doneFolder = 'console.data_files.done';
foreach ($urls as $name => $url) {
$saveTo = Yii::getPathOfAlias($folder) . '/' . $name . '.xml';
$donePath = Yii::getPathOfAlias($doneFolder) . '/' . $name . '.xml';
try {
if (is_file($saveTo)) {
$this->analyzeFile($saveTo, $url);
rename($saveTo, $donePath);
continue;
}
if (is_file($donePath)) {
continue;
}
echo 'Grabbing using ' . $name . " ( {$url} ) ";
$response = file_get_contents_curl($url);
sleep(2);
if ($response === false) {
throw new CException('Failed');
}
echo "Success.\n";
file_put_contents($saveTo, $response);
$this->analyzeFile($saveTo, $url);
rename($saveTo, $donePath);
} catch (Exception $e) {
echo "Failed. {$e->getMessage()}\n";
}
}
}
示例15: dbConnect
//Database connection fails
//--------------------------------------------------------------//
print 'Database error';
exit;
}
// connect to database
dbConnect();
if (!isset($HTTP_RAW_POST_DATA)) {
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
}
$data = json_decode($HTTP_RAW_POST_DATA);
$time = time();
$complaint_simulator_email = 'complaint@simulator.amazonses.com';
//Confirm SNS subscription
if ($data->Type == 'SubscriptionConfirmation') {
file_get_contents_curl($data->SubscribeURL);
} else {
//detect complaints
$obj = json_decode($data->Message);
$notificationType = $obj->{'notificationType'};
$problem_email = $obj->{'complaint'}->{'complainedRecipients'};
$problem_email = $problem_email[0]->{'emailAddress'};
$from_email = get_email($obj->{'mail'}->{'source'});
$messageId = $obj->{'mail'}->{'messageId'};
$from_email = $from_email[0];
//check if email is valid, if not, exit
if (!filter_var($problem_email, FILTER_VALIDATE_EMAIL)) {
exit;
}
if ($notificationType == 'Complaint') {
//Update complaint status