本文整理汇总了PHP中curl::download方法的典型用法代码示例。如果您正苦于以下问题:PHP curl::download方法的具体用法?PHP curl::download怎么用?PHP curl::download使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类curl
的用法示例。
在下文中一共展示了curl::download方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_file
public function get_file($url, $file = '')
{
global $CFG;
//$CFG->repository_no_delete = true;
$path = $this->prepare_file($file);
$fp = fopen($path, 'w');
$c = new curl();
$c->download(array(array('url' => $url, 'file' => $fp)));
return $path;
}
示例2: get_file
/**
* Download a file from alfresco
*
* @param string $uuid a unique id of directory in alfresco
* @param string $path path to a directory
* @return array
*/
public function get_file($uuid, $file = '') {
$node = $this->user_session->getNode($this->store, $uuid);
$url = $this->get_url($node);
$path = $this->prepare_file($file);
$fp = fopen($path, 'w');
$c = new curl;
$c->download(array(array('url'=>$url, 'file'=>$fp)));
fclose($fp);
return array('path'=>$path, 'url'=>$url);
}
示例3: create_from_url
/**
* Static method to create cache from url
*
* @param mixed $ref file reference
* @param string $url file url
* @param array $options options
* @return string cached file path
*/
public static function create_from_url($ref, $url, $options = array())
{
$instance = self::get_instance($options);
$cachedfilepath = $instance->generate_filepath($ref);
$fp = fopen($cachedfilepath, 'w');
$curl = new curl();
$curl->download(array(array('url' => $url, 'file' => $fp)));
// Must close file handler.
fclose($fp);
return $cachedfilepath;
}
示例4: get_file
/**
*
* @global object $CFG
* @param string $photo_id
* @param string $file
* @return string
*/
public function get_file($photo_id, $file = '')
{
global $CFG;
$info = $this->flickr->photos_getInfo($photo_id);
if ($info['owner']['realname']) {
$author = $info['owner']['realname'];
} else {
$author = $info['owner']['username'];
}
$copyright = get_string('author', 'repository') . ': ' . $author;
$result = $this->flickr->photos_getSizes($photo_id);
// download link
$source = '';
// flickr photo page
$url = '';
if (!empty($result[4])) {
$source = $result[4]['source'];
$url = $result[4]['url'];
} elseif (!empty($result[3])) {
$source = $result[3]['source'];
$url = $result[3]['url'];
} elseif (!empty($result[2])) {
$source = $result[2]['source'];
$url = $result[2]['url'];
}
$path = $this->prepare_file($file);
$fp = fopen($path, 'w');
$c = new curl();
$c->download(array(array('url' => $source, 'file' => $fp)));
// must close file handler, otherwise gd lib will fail to process it
fclose($fp);
if (!empty($this->usewatermarks)) {
$img = new moodle_image($path);
$img->watermark($copyright, array(10, 10), array('ttf' => true, 'fontsize' => 12))->saveas($path);
}
return array('path' => $path, 'url' => $url, 'author' => $info['owner']['realname'], 'license' => $this->license4moodle($info['license']));
}
示例5: get_file
/**
* Download a file, this function can be overridden by subclass. {@link curl}
*
* @param string $url the url of file
* @param string $filename save location
* @return array with elements:
* path: internal location of the file
* url: URL to the source (from parameters)
*/
public function get_file($url, $filename = '') {
global $CFG;
$path = $this->prepare_file($filename);
$fp = fopen($path, 'w');
$c = new curl;
$result = $c->download(array(array('url'=>$url, 'file'=>$fp)));
// Close file handler.
fclose($fp);
if (empty($result)) {
unlink($path);
return null;
}
return array('path'=>$path, 'url'=>$url);
}
示例6: get_file
/**
* Download a file from alfresco - do we use this?
*
* @param string $uuid a unique id of directory in alfresco
* @param string $path path to a directory
* @return array|null
*/
public function get_file($uuid, $file = '') {
//error_log("get_file($uuid, '{$file}');");
$node = $this->elis_files->get_info($uuid);
if (empty($node)) {
return null;
}
// Test to make sure this works with, say, a teacher or someone non-admin
$username = '';
/// Check for a non-text file type to just pass through to the end user.
$mimetype = !empty($node->filemimetype) ? $node->filemimetype : '';
$ticket = elis_files_utils_get_ticket('refresh', $username);
$url = str_replace($node->filename, urlencode($node->filename), $node->fileurl) . '?alf_ticket=' .
$ticket;
$path = $this->prepare_file($file);
$fp = fopen($path, 'w');
$c = new curl;
$response = $c->download(array(array('url'=>$url, 'file'=>$fp)));
return array('path' => $path, 'url' => $url);
}
示例7: get_file
public function get_file($uuid, $file = '')
{
global $CFG;
$node = $this->sess->getNode($this->store, $uuid);
$url = $this->get_url($node);
$path = $this->prepare_file($file);
$fp = fopen($path, 'w');
$c = new curl();
$c->download(array(array('url' => $url, 'file' => $fp)));
return $path;
}