本文整理汇总了PHP中Api::getPublicKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Api::getPublicKey方法的具体用法?PHP Api::getPublicKey怎么用?PHP Api::getPublicKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Api
的用法示例。
在下文中一共展示了Api::getPublicKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getScriptTag
/**
* Returns <script> sections to include Uploadcare widget
*
* @param string $version Uploadcare version
* @param bool $async
* @return string
*/
public function getScriptTag($version = null, $async = false)
{
$async_attr = $async ? 'async="true"' : '';
$result = <<<EOT
<script>UPLOADCARE_PUBLIC_KEY = "{$this->api->getPublicKey()}";</script>
<script {$async_attr} src="{$this->getScriptSrc($version)}" charset="UTF-8"></script>
EOT;
return $result;
}
示例2: createGroup
/**
* Create group from array of File objects
*
* @param array $files
* @return Group
*/
public function createGroup($files)
{
$data = array('pub_key' => $this->api->getPublicKey());
foreach ($files as $i => $file) {
$data["files[{$i}]"] = $file->getUuid();
}
$ch = $this->__initRequest('group');
$this->__setRequestType($ch);
$this->__setData($ch, $data);
$this->__setHeaders($ch);
$resp = $this->__runRequest($ch);
$group = $this->api->getGroup($resp->id);
return $group;
}
示例3: fromContent
/**
* Upload file from string using mime-type.
*
* @param string $content
* @param string $mime_type
* @return File
*/
public function fromContent($content, $mime_type)
{
$tmpfile = tempnam(sys_get_temp_dir(), 'ucr');
$temp = fopen($tmpfile, 'w');
fwrite($temp, $content);
fclose($temp);
$data = array('UPLOADCARE_PUB_KEY' => $this->api->getPublicKey(), 'file' => sprintf('@%s;type=%s', $tmpfile, $mime_type));
$ch = $this->__initRequest('base');
$this->__setRequestType($ch);
$this->__setData($ch, $data);
$this->__setHeaders($ch);
$data = $this->__runRequest($ch);
$file_id = $data->file;
return new File($file_id, $this->api);
}
示例4: fromPath
/**
* Upload file from local path.
*
* @param string $path
* @param string $mime_type
* @return File
*/
public function fromPath($path, $mime_type = false)
{
if (function_exists('curl_file_create')) {
if ($mime_type) {
$f = curl_file_create($path, $mime_type);
} else {
$f = curl_file_create($path);
}
} else {
if ($mime_type) {
$f = '@' . $path . ';type=' . $mime_type;
} else {
$f = '@' . $path;
}
}
$data = array('UPLOADCARE_PUB_KEY' => $this->api->getPublicKey(), 'file' => $f);
$ch = $this->__initRequest('base');
$this->__setRequestType($ch);
$this->__setData($ch, $data);
$this->__setHeaders($ch);
$data = $this->__runRequest($ch);
$file_id = $data->file;
return new File($file_id, $this->api);
}
示例5: getScriptTag
/**
* Returns <script> sections to include Uploadcare widget
*
* @param string $version Uploadcare version
* @return string
*/
public function getScriptTag($version = null)
{
$result = sprintf('<script>UPLOADCARE_PUBLIC_KEY = "%s";</script>', $this->api->getPublicKey());
$result .= sprintf('<script async="async" src="%s"></script>', $this->getScriptSrc($version));
return $result;
}