[更新]增加 Ali OSS 支持

This commit is contained in:
Anyon 2017-05-10 17:21:03 +08:00
parent 94f0e57285
commit d94f9d29a6
14 changed files with 388 additions and 51 deletions

View File

@ -7,12 +7,18 @@
<label class="col-sm-2 control-label">Storage <span class="nowrap">(存储引擎)</span></label>
<div class='col-sm-8'>
<select class="layui-input" name="storage_type" required="required">
<!--{if sysconf('storage_type')!=='qiniu'}-->
<option selected value='local'>本地服务器</option>
<!--{if sysconf('storage_type') eq 'qiniu'}-->
<option value='local'>本地服务器</option>
<option selected="selected" value='qiniu'>七牛云存储</option>
<option value='oss'>AliOSS存储</option>
<!--{elseif sysconf('storage_type') eq 'oss'}-->
<option value='local'>本地服务器</option>
<option value='qiniu'>七牛云存储</option>
<option selected="selected" value='oss'>AliOSS存储</option>
<!--{else}-->
<option value='local'>本地服务器</option>
<option selected value='qiniu'>七牛云存储</option>
<option selected="selected" value='qiniu'>七牛云存储</option>
<option value='oss'>AliOSS存储</option>
<!--{/if}-->
</select>
<div class="help-block" data-storage-type="qiniu">
@ -20,6 +26,9 @@
<a target="_blank" href="https://portal.qiniu.com/signup?code=3lhz6nmnwbple">免费申请10G存储空间</a>
申请成功后添加公开bucket空间
</div>
<div class="help-block" data-storage-type="oss">
若还没有Ali-OSS存储账号请点击 <a target="_blank" href="https://oss.console.aliyun.com">创建AliOSS存储空间</a>
</div>
</div>
</div>
@ -30,29 +39,29 @@
<div class='col-sm-8'>
<select class="layui-input" name="storage_qiniu_region" required="required">
{if sysconf('storage_qiniu_region') eq '华东'}
<!--{if sysconf('storage_qiniu_region') eq '华东'}-->
<option selected value='华东'>华东</option>
{else}
<!--{else}-->
<option value='华东'>华东</option>
{/if}
<!--{/if}-->
{if sysconf('storage_qiniu_region') eq '华北'}
<!--{if sysconf('storage_qiniu_region') eq '华北'}-->
<option selected value='华北'>华北</option>
{else}
<!--{else}-->
<option value='华北'>华北</option>
{/if}
<!--{/if}-->
{if sysconf('storage_qiniu_region') eq '华南'}
<!--{if sysconf('storage_qiniu_region') eq '华南'}-->
<option selected value='华南'>华南</option>
{else}
<!--{else}-->
<option value='华南'>华南</option>
{/if}
<!--{/if}-->
{if sysconf('storage_qiniu_region') eq '北美'}
<!--{if sysconf('storage_qiniu_region') eq '北美'}-->
<option selected value='北美'>北美</option>
{else}
<!--{else}-->
<option value='北美'>北美</option>
{/if}
<!--{/if}-->
</select>
<p class="help-block">七牛云存储空间所在区域,需要严格对应储存所在区域才能上传文件</p>
@ -63,13 +72,13 @@
<label class="col-sm-2 control-label">Protocol <span class="nowrap">(访问协议)</span></label>
<div class='col-sm-8'>
<select class="layui-input" name="storage_qiniu_is_https" required="required">
{if sysconf('storage_qiniu_is_https')!=='1'}
<!--{if sysconf('storage_qiniu_is_https')!=='1'}-->
<option selected value='0'>HTTP</option>
<option value='1'>HTTPS</option>
{else}
<!--{else}-->
<option value='0'>HTTP</option>
<option selected value='1'>HTTPS</option>
{/if}
<!--{/if}-->
</select>
<p class="help-block">七牛云资源访问协议HTTP HTTPSHTTPS 需要配置证书才能使用</p>
</div>
@ -117,6 +126,60 @@
</div>
</div>
<div class="form-group" data-storage-type="oss">
<label class="col-sm-2 control-label">Protocol <span class="nowrap">(访问协议)</span></label>
<div class='col-sm-8'>
<select class="layui-input" name="storage_oss_is_https" required="required">
<!--{if sysconf('storage_oss_is_https')!=='1'}-->
<option selected value='0'>HTTP</option>
<option value='1'>HTTPS</option>
<!--{else}-->
<option value='0'>HTTP</option>
<option selected value='1'>HTTPS</option>
<!--{/if}-->
</select>
<p class="help-block">AliOSS资源访问协议HTTP HTTPSHTTPS 需要配置证书才能使用</p>
</div>
</div>
<div class="form-group" data-storage-type="oss">
<label class="col-sm-2 control-label">Bucket <span class="nowrap">(空间名称)</span></label>
<div class='col-sm-8'>
<input type="text" name="storage_oss_bucket" required="required" title="请输入OSS存储 Bucket (空间名称)"
placeholder="请输入OSS存储 Bucket (空间名称)" value="{:sysconf('storage_oss_bucket')}" class="layui-input">
<p class="help-block">填写OSS存储空间名称static</p>
</div>
</div>
<div class="form-group" data-storage-type="oss">
<label class="col-sm-2 control-label">Domain <span class="nowrap">(访问域名)</span></label>
<div class='col-sm-8'>
<input type="text" name="storage_oss_domain" required="required" title="请输入OSS存储 Domain (访问域名)"
placeholder="请输入七牛云存储 Domain (访问域名)" value="{:sysconf('storage_oss_domain')}" class="layui-input">
<p class="help-block">填写OSS存储外部访问域名static.ctolog.cc</p>
</div>
</div>
<div class="form-group" data-storage-type="oss">
<label class="col-sm-2 control-label">AccessKey <span class="nowrap">(访问密钥)</span></label>
<div class='col-sm-8'>
<input type="text" name="storage_oss_keyid" required="required" title="请输入16位 OSS AccessKey (访问密钥)"
placeholder="请输入OSS AccessKey (访问密钥)" value="{:sysconf('storage_oss_keyid')}" maxlength="16" class="layui-input">
<p class="help-block">可以在 阿里云 个人中心 设置并获取到访问密钥</p>
</div>
</div>
<div class="form-group" data-storage-type="oss">
<label class="col-sm-2 control-label">SecretKey <span class="nowrap">(安全密钥)</span></label>
<div class='col-sm-8'>
<input type="password" name="storage_oss_secret" required="required" title="请输入30位 OSS SecretKey (安全密钥)"
placeholder="请输入七牛云 SecretKey (安全密钥)" value="{:sysconf('storage_oss_secret')}" maxlength="30" class="layui-input">
<p class="help-block">可以在 七牛云 个人中心 设置并获取到安全密钥</p>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="col-sm-4 col-sm-offset-2">

View File

@ -24,7 +24,8 @@
"topthink/think-captcha": "^1.0",
"topthink/think-mongo": "^1.1",
"topthink/think-queue": "^1.0",
"endroid/qrcode": "^1.9"
"endroid/qrcode": "^1.9",
"aliyuncs/oss-sdk-php": "^2.2"
},
"extra": {
"think-path": "thinkphp"

View File

@ -15,11 +15,13 @@
namespace service;
use Exception;
use think\Log;
use think\Config;
use OSS\Core\OssException;
use OSS\OssClient;
use Qiniu\Auth;
use Qiniu\Storage\BucketManager;
use Qiniu\Storage\UploadManager;
use think\Config;
use think\Log;
/**
* 系统文件服务
@ -129,6 +131,14 @@ class FileService {
return (sysconf('storage_qiniu_is_https') ? 'https' : 'http') . '://' . sysconf('storage_qiniu_domain') . '/';
}
/**
* 获取AliOss URL前缀
* @return string
*/
public static function getBaseUriOss() {
return (sysconf('storage_oss_is_https') ? 'https' : 'http') . '://' . sysconf('storage_oss_domain') . '/';
}
/**
* 检查文件是否已经存在
* @param string $filename
@ -196,12 +206,8 @@ class FileService {
$filepath = ROOT_PATH . 'static/upload/' . $filename;
!file_exists(dirname($filepath)) && mkdir(dirname($filepath), '0755', true);
if (file_put_contents($filepath, $bodycontent)) {
return [
'file' => $filepath,
'hash' => md5_file($filepath),
'key' => "upload/{$filename}",
'url' => pathinfo(request()->baseFile(true), PATHINFO_DIRNAME) . '/upload/' . $filename,
];
$url = pathinfo(request()->baseFile(true), PATHINFO_DIRNAME) . '/upload/' . $filename;
return ['file' => $filepath, 'hash' => md5_file($filepath), 'key' => "upload/{$filename}", 'url' => $url];
}
} catch (Exception $err) {
Log::error('本地文件存储失败, ' . var_export($err, true));
@ -229,4 +235,21 @@ class FileService {
return $result;
}
/**
* 阿里云OSS
* @param type $filename
* @param type $bodycontent
* @return type
*/
public static function oss($filename, $bodycontent) {
try {
$ossClient = new OssClient(sysconf('storage_oss_keyid'), sysconf('storage_oss_secret'), self::getBaseUriOss(), true);
$result = $ossClient->putObject(sysconf('storage_oss_bucket'), $filename, $bodycontent);
return ['file' => $filename, 'hash' => $result['content-md5'], 'key' => $filename, 'url' => $result['oss-request-url']];
} catch (OssException $err) {
Log::error('阿里云OSS文件上传失败, ' . var_export($err, true));
return null;
}
}
}

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit5cb6a9364227ba2158c05a13f4655c4b::getLoader();
return ComposerAutoloaderInitd15b7724a4339f816295e7d8e017c8aa::getLoader();

View File

@ -21,6 +21,66 @@ return array(
'Endroid\\QrCode\\Factory\\QrCodeFactory' => $vendorDir . '/endroid/qrcode/src/Factory/QrCodeFactory.php',
'Endroid\\QrCode\\QrCode' => $vendorDir . '/endroid/qrcode/src/QrCode.php',
'Ip2Region' => $vendorDir . '/zoujingli/ip2region/Ip2Region.php',
'OSS\\Core\\MimeTypes' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php',
'OSS\\Core\\OssException' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php',
'OSS\\Core\\OssUtil' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php',
'OSS\\Http\\RequestCore' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php',
'OSS\\Http\\RequestCore_Exception' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore_Exception.php',
'OSS\\Http\\ResponseCore' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Http/ResponseCore.php',
'OSS\\Model\\BucketInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php',
'OSS\\Model\\BucketListInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php',
'OSS\\Model\\CnameConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php',
'OSS\\Model\\CorsConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php',
'OSS\\Model\\CorsRule' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php',
'OSS\\Model\\GetLiveChannelHistory' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php',
'OSS\\Model\\GetLiveChannelInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php',
'OSS\\Model\\GetLiveChannelStatus' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php',
'OSS\\Model\\LifecycleAction' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php',
'OSS\\Model\\LifecycleConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php',
'OSS\\Model\\LifecycleRule' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php',
'OSS\\Model\\ListMultipartUploadInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/ListMultipartUploadInfo.php',
'OSS\\Model\\ListPartsInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/ListPartsInfo.php',
'OSS\\Model\\LiveChannelConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelConfig.php',
'OSS\\Model\\LiveChannelHistory' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelHistory.php',
'OSS\\Model\\LiveChannelInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelInfo.php',
'OSS\\Model\\LiveChannelListInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php',
'OSS\\Model\\LoggingConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php',
'OSS\\Model\\ObjectInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php',
'OSS\\Model\\ObjectListInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php',
'OSS\\Model\\PartInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php',
'OSS\\Model\\PrefixInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php',
'OSS\\Model\\RefererConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php',
'OSS\\Model\\UploadInfo' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php',
'OSS\\Model\\WebsiteConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php',
'OSS\\Model\\XmlConfig' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php',
'OSS\\OssClient' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/OssClient.php',
'OSS\\Result\\AclResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php',
'OSS\\Result\\AppendResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php',
'OSS\\Result\\BodyResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php',
'OSS\\Result\\CallbackResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php',
'OSS\\Result\\CopyObjectResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php',
'OSS\\Result\\DeleteObjectsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php',
'OSS\\Result\\ExistResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php',
'OSS\\Result\\GetCnameResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php',
'OSS\\Result\\GetCorsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php',
'OSS\\Result\\GetLifecycleResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php',
'OSS\\Result\\GetLiveChannelHistoryResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelHistoryResult.php',
'OSS\\Result\\GetLiveChannelInfoResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelInfoResult.php',
'OSS\\Result\\GetLiveChannelStatusResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelStatusResult.php',
'OSS\\Result\\GetLoggingResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php',
'OSS\\Result\\GetRefererResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php',
'OSS\\Result\\GetWebsiteResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php',
'OSS\\Result\\HeaderResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php',
'OSS\\Result\\InitiateMultipartUploadResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php',
'OSS\\Result\\ListBucketsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php',
'OSS\\Result\\ListLiveChannelResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php',
'OSS\\Result\\ListMultipartUploadResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php',
'OSS\\Result\\ListObjectsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php',
'OSS\\Result\\ListPartsResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php',
'OSS\\Result\\PutLiveChannelResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php',
'OSS\\Result\\PutSetDeleteResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/PutSetDeleteResult.php',
'OSS\\Result\\Result' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php',
'OSS\\Result\\UploadPartResult' => $vendorDir . '/aliyuncs/oss-sdk-php/src/OSS/Result/UploadPartResult.php',
'Qiniu\\Auth' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/Auth.php',
'Qiniu\\Config' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/Config.php',
'Qiniu\\Etag' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/Etag.php',
@ -54,6 +114,7 @@ return array(
'Wechat\\WechatCustom' => $vendorDir . '/zoujingli/wechat-php-sdk/Wechat/WechatCustom.php',
'Wechat\\WechatDevice' => $vendorDir . '/zoujingli/wechat-php-sdk/Wechat/WechatDevice.php',
'Wechat\\WechatExtends' => $vendorDir . '/zoujingli/wechat-php-sdk/Wechat/WechatExtends.php',
'Wechat\\WechatHardware' => $vendorDir . '/zoujingli/wechat-php-sdk/Wechat/WechatHardware.php',
'Wechat\\WechatMedia' => $vendorDir . '/zoujingli/wechat-php-sdk/Wechat/WechatMedia.php',
'Wechat\\WechatMenu' => $vendorDir . '/zoujingli/wechat-php-sdk/Wechat/WechatMenu.php',
'Wechat\\WechatOauth' => $vendorDir . '/zoujingli/wechat-php-sdk/Wechat/WechatOauth.php',

View File

@ -14,5 +14,6 @@ return array(
'Wechat\\' => array($vendorDir . '/zoujingli/wechat-php-sdk/Wechat'),
'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'),
'Qiniu\\' => array($vendorDir . '/qiniu/php-sdk/src/Qiniu'),
'OSS\\' => array($vendorDir . '/aliyuncs/oss-sdk-php/src/OSS'),
'Endroid\\QrCode\\' => array($vendorDir . '/endroid/qrcode/src'),
);

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit5cb6a9364227ba2158c05a13f4655c4b
class ComposerAutoloaderInitd15b7724a4339f816295e7d8e017c8aa
{
private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderInit5cb6a9364227ba2158c05a13f4655c4b
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit5cb6a9364227ba2158c05a13f4655c4b', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitd15b7724a4339f816295e7d8e017c8aa', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit5cb6a9364227ba2158c05a13f4655c4b', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitd15b7724a4339f816295e7d8e017c8aa', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit5cb6a9364227ba2158c05a13f4655c4b::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitd15b7724a4339f816295e7d8e017c8aa::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@ -48,19 +48,19 @@ class ComposerAutoloaderInit5cb6a9364227ba2158c05a13f4655c4b
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit5cb6a9364227ba2158c05a13f4655c4b::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitd15b7724a4339f816295e7d8e017c8aa::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire5cb6a9364227ba2158c05a13f4655c4b($fileIdentifier, $file);
composerRequired15b7724a4339f816295e7d8e017c8aa($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire5cb6a9364227ba2158c05a13f4655c4b($fileIdentifier, $file)
function composerRequired15b7724a4339f816295e7d8e017c8aa($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit5cb6a9364227ba2158c05a13f4655c4b
class ComposerStaticInitd15b7724a4339f816295e7d8e017c8aa
{
public static $files = array (
'9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php',
@ -34,6 +34,10 @@ class ComposerStaticInit5cb6a9364227ba2158c05a13f4655c4b
array (
'Qiniu\\' => 6,
),
'O' =>
array (
'OSS\\' => 4,
),
'E' =>
array (
'Endroid\\QrCode\\' => 15,
@ -74,6 +78,10 @@ class ComposerStaticInit5cb6a9364227ba2158c05a13f4655c4b
array (
0 => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu',
),
'OSS\\' =>
array (
0 => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS',
),
'Endroid\\QrCode\\' =>
array (
0 => __DIR__ . '/..' . '/endroid/qrcode/src',
@ -96,6 +104,66 @@ class ComposerStaticInit5cb6a9364227ba2158c05a13f4655c4b
'Endroid\\QrCode\\Factory\\QrCodeFactory' => __DIR__ . '/..' . '/endroid/qrcode/src/Factory/QrCodeFactory.php',
'Endroid\\QrCode\\QrCode' => __DIR__ . '/..' . '/endroid/qrcode/src/QrCode.php',
'Ip2Region' => __DIR__ . '/..' . '/zoujingli/ip2region/Ip2Region.php',
'OSS\\Core\\MimeTypes' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php',
'OSS\\Core\\OssException' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php',
'OSS\\Core\\OssUtil' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php',
'OSS\\Http\\RequestCore' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php',
'OSS\\Http\\RequestCore_Exception' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore_Exception.php',
'OSS\\Http\\ResponseCore' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Http/ResponseCore.php',
'OSS\\Model\\BucketInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php',
'OSS\\Model\\BucketListInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php',
'OSS\\Model\\CnameConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php',
'OSS\\Model\\CorsConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php',
'OSS\\Model\\CorsRule' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php',
'OSS\\Model\\GetLiveChannelHistory' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php',
'OSS\\Model\\GetLiveChannelInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php',
'OSS\\Model\\GetLiveChannelStatus' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php',
'OSS\\Model\\LifecycleAction' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php',
'OSS\\Model\\LifecycleConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php',
'OSS\\Model\\LifecycleRule' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php',
'OSS\\Model\\ListMultipartUploadInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/ListMultipartUploadInfo.php',
'OSS\\Model\\ListPartsInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/ListPartsInfo.php',
'OSS\\Model\\LiveChannelConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelConfig.php',
'OSS\\Model\\LiveChannelHistory' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelHistory.php',
'OSS\\Model\\LiveChannelInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelInfo.php',
'OSS\\Model\\LiveChannelListInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php',
'OSS\\Model\\LoggingConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php',
'OSS\\Model\\ObjectInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php',
'OSS\\Model\\ObjectListInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php',
'OSS\\Model\\PartInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php',
'OSS\\Model\\PrefixInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php',
'OSS\\Model\\RefererConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php',
'OSS\\Model\\UploadInfo' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php',
'OSS\\Model\\WebsiteConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php',
'OSS\\Model\\XmlConfig' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php',
'OSS\\OssClient' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/OssClient.php',
'OSS\\Result\\AclResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php',
'OSS\\Result\\AppendResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php',
'OSS\\Result\\BodyResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php',
'OSS\\Result\\CallbackResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php',
'OSS\\Result\\CopyObjectResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php',
'OSS\\Result\\DeleteObjectsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php',
'OSS\\Result\\ExistResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php',
'OSS\\Result\\GetCnameResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php',
'OSS\\Result\\GetCorsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php',
'OSS\\Result\\GetLifecycleResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php',
'OSS\\Result\\GetLiveChannelHistoryResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelHistoryResult.php',
'OSS\\Result\\GetLiveChannelInfoResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelInfoResult.php',
'OSS\\Result\\GetLiveChannelStatusResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelStatusResult.php',
'OSS\\Result\\GetLoggingResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php',
'OSS\\Result\\GetRefererResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php',
'OSS\\Result\\GetWebsiteResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php',
'OSS\\Result\\HeaderResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php',
'OSS\\Result\\InitiateMultipartUploadResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php',
'OSS\\Result\\ListBucketsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php',
'OSS\\Result\\ListLiveChannelResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php',
'OSS\\Result\\ListMultipartUploadResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php',
'OSS\\Result\\ListObjectsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php',
'OSS\\Result\\ListPartsResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php',
'OSS\\Result\\PutLiveChannelResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php',
'OSS\\Result\\PutSetDeleteResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/PutSetDeleteResult.php',
'OSS\\Result\\Result' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php',
'OSS\\Result\\UploadPartResult' => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS/Result/UploadPartResult.php',
'Qiniu\\Auth' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/Auth.php',
'Qiniu\\Config' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/Config.php',
'Qiniu\\Etag' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/Etag.php',
@ -129,6 +197,7 @@ class ComposerStaticInit5cb6a9364227ba2158c05a13f4655c4b
'Wechat\\WechatCustom' => __DIR__ . '/..' . '/zoujingli/wechat-php-sdk/Wechat/WechatCustom.php',
'Wechat\\WechatDevice' => __DIR__ . '/..' . '/zoujingli/wechat-php-sdk/Wechat/WechatDevice.php',
'Wechat\\WechatExtends' => __DIR__ . '/..' . '/zoujingli/wechat-php-sdk/Wechat/WechatExtends.php',
'Wechat\\WechatHardware' => __DIR__ . '/..' . '/zoujingli/wechat-php-sdk/Wechat/WechatHardware.php',
'Wechat\\WechatMedia' => __DIR__ . '/..' . '/zoujingli/wechat-php-sdk/Wechat/WechatMedia.php',
'Wechat\\WechatMenu' => __DIR__ . '/..' . '/zoujingli/wechat-php-sdk/Wechat/WechatMenu.php',
'Wechat\\WechatOauth' => __DIR__ . '/..' . '/zoujingli/wechat-php-sdk/Wechat/WechatOauth.php',
@ -314,9 +383,9 @@ class ComposerStaticInit5cb6a9364227ba2158c05a13f4655c4b
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit5cb6a9364227ba2158c05a13f4655c4b::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit5cb6a9364227ba2158c05a13f4655c4b::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit5cb6a9364227ba2158c05a13f4655c4b::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitd15b7724a4339f816295e7d8e017c8aa::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd15b7724a4339f816295e7d8e017c8aa::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd15b7724a4339f816295e7d8e017c8aa::$classMap;
}, null, ClassLoader::class);
}

View File

@ -49,18 +49,18 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/wechat-php-sdk.git",
"reference": "38f86a42b1c0058d889a0969190540037629606a"
"reference": "caeb3d93a4c7ad78c6aaf7bcdbb0086f0e1f3ae8"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/zoujingli/wechat-php-sdk/38f86a42b1c0058d889a0969190540037629606a.zip",
"reference": "38f86a42b1c0058d889a0969190540037629606a",
"url": "https://files.phpcomposer.com/files/zoujingli/wechat-php-sdk/caeb3d93a4c7ad78c6aaf7bcdbb0086f0e1f3ae8.zip",
"reference": "caeb3d93a4c7ad78c6aaf7bcdbb0086f0e1f3ae8",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"time": "2017-04-19 13:34:58",
"time": "2017-05-10 07:41:59",
"type": "project",
"installation-source": "dist",
"autoload": {
@ -496,5 +496,48 @@
"qrcode",
"symfony"
]
},
{
"name": "aliyuncs/oss-sdk-php",
"version": "v2.2.4",
"version_normalized": "2.2.4.0",
"source": {
"type": "git",
"url": "https://github.com/aliyun/aliyun-oss-php-sdk.git",
"reference": "0b9b85b6c5c38cfc4ef3b0205a5a62d1e36acf2e"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/aliyun/aliyun-oss-php-sdk/0b9b85b6c5c38cfc4ef3b0205a5a62d1e36acf2e.zip",
"reference": "0b9b85b6c5c38cfc4ef3b0205a5a62d1e36acf2e",
"shasum": ""
},
"require": {
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "~1.0"
},
"time": "2017-04-25 09:15:12",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"OSS\\": "src/OSS"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Aliyuncs",
"homepage": "http://www.aliyun.com"
}
],
"description": "Aliyun OSS SDK for PHP",
"homepage": "http://www.aliyun.com/product/oss/"
}
]

View File

@ -1,6 +1,6 @@
The MIT License
Copyright (c) 2009-2015 walkor<walkor@workerman.net> and contributors (see https://github.com/walkor/workerman/contributors)
Copyright (c) 2014-2017 Anyon<zoujingli@qq.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -13,7 +13,7 @@ use Wechat\Lib\Tools;
class WechatDevice extends Common {
const SHAKEAROUND_DEVICE_APPLYID = '/shakearound/device/applyid?'; //申请设备ID
const SHAKEAROUND_DEVICE_APPLYSTATUS = '/shakearound/device/applystatus?'; //查询设备ID申请审核状态
const SHAKEAROUND_DEVICE_APPLYSTATUS = '/shakearound/device/applystatus?'; //查询设备ID申请审核状态
const SHAKEAROUND_DEVICE_UPDATE = '/shakearound/device/update?'; //编辑设备信息
const SHAKEAROUND_DEVICE_SEARCH = '/shakearound/device/search?'; //查询设备列表
const SHAKEAROUND_DEVICE_BINDLOCATION = '/shakearound/device/bindlocation?'; //配置设备与门店ID的关系
@ -59,7 +59,7 @@ class WechatDevice extends Common {
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}
$data = array("apply_id" => $apply_id);
$data = array("apply_id" => $apply_id);
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_APPLYSTATUS . "access_token={$this->access_token}", Tools::json_encode($data));
if ($result) {
$json = json_decode($result, true);
@ -162,11 +162,11 @@ class WechatDevice extends Common {
* @param type $poi_appid 目标微信appid
* @return boolean
*/
public function bindLocationOtherShakeAroundDevice($device_identifier,$poi_id,$poi_appid) {
public function bindLocationOtherShakeAroundDevice($device_identifier, $poi_id, $poi_appid) {
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}
$data = array('device_identifier' => $device_identifier, 'poi_id' => $poi_id,"type"=>2,"poi_appid"=>$poi_appid);
$data = array('device_identifier' => $device_identifier, 'poi_id' => $poi_id, "type" => 2, "poi_appid" => $poi_appid);
$result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_BINDLOCATION . "access_token={$this->access_token}", Tools::json_encode($data));
if ($result) {
$json = json_decode($result, true);

View File

@ -82,6 +82,53 @@ class WechatMedia extends Common {
return false;
}
/**
* 获取临时素材(认证后的订阅号可用) 包含返回的http头信息
* @param string $media_id 媒体文件id
* @param bool $is_video 是否为视频文件,默认为否
* @return bool|array
*/
public function getMediaWithHttpInfo($media_id, $is_video = false) {
if (!$this->access_token && !$this->getAccessToken()) {
return false;
}
//原先的上传多媒体文件接口使用 self::UPLOAD_MEDIA_URL 前缀
//如果要获取的素材是视频文件时不能使用https协议必须更换成http协议
$url_prefix = $is_video ? str_replace('https', 'http', self::API_URL_PREFIX) : self::API_URL_PREFIX;
$url = $url_prefix . self::MEDIA_GET_URL . "access_token={$this->access_token}" . '&media_id=' . $media_id;
$oCurl = curl_init();
if (stripos($url, "https://") !== FALSE) {
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($oCurl, CURLOPT_SSLVERSION, 1);
}
curl_setopt($oCurl, CURLOPT_URL, $url);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
$sContent = curl_exec($oCurl);
$aStatus = curl_getinfo($oCurl);
$result = [];
if (intval($aStatus["http_code"]) !== 200) {
return false;
}
if ($sContent) {
if (is_string($sContent)) {
$json = json_decode($sContent, true);
if (isset($json['errcode'])) {
$this->errCode = $json['errcode'];
$this->errMsg = $json['errmsg'];
return $this->checkRetry(__FUNCTION__, func_get_args());
}
}
$result['content'] = $sContent;
$result['info'] = $aStatus;
return $result;
}
return false;
}
/**
* 上传图片本接口所上传的图片不占用公众号的素材库中图片数量的5000个的限制。图片仅支持jpg/png格式大小必须在1MB以下。 (认证后的订阅号可用)
* 注意:上传大文件时可能需要先调用 set_time_limit(0) 避免超时

View File

@ -116,6 +116,33 @@ class WechatPay {
return $result;
}
/**
* 创建刷卡支付参数包
* @param string $auth_code 授权Code号
* @param string $out_trade_no 商户订单号
* @param int $total_fee 支付费用
* @param string $body 订单标识
* @param null $goods_tag 商品标签
* @return array|bool
*/
public function createMicroPay($auth_code, $out_trade_no, $total_fee, $body, $goods_tag = null) {
$data = array(
"appid" => $this->appid,
"mch_id" => $this->mch_id,
"body" => $body,
"out_trade_no" => $out_trade_no,
"total_fee" => $total_fee,
"auth_code" => $auth_code,
"spbill_create_ip" => Tools::getAddress()
);
empty($goods_tag) || $data['goods_tag'] = $goods_tag;
$json = Tools::xml2arr($this->postXml($data, self::MCH_BASE_URL . '/pay/micropay'));
if (!empty($json) && false === $this->_parseResult($json)) {
return false;
}
return $json;
}
/**
* 支付通知验证处理
* @return bool|array

View File

@ -4,7 +4,6 @@ namespace Wechat;
use Wechat\Lib\Common;
use Wechat\Lib\Tools;
use Wechat\Loader;
/**
* 微信前端 JavaScript 签名SDK
@ -113,6 +112,9 @@ class WechatScript extends Common {
'translateVoice', 'getNetworkType', 'openLocation', 'getLocation',
'openProductSpecificView', 'addCard', 'chooseCard', 'openCard',
'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice',
'openWXDeviceLib', 'closeWXDeviceLib', 'getWXDeviceInfos', 'sendDataToWXDevice', 'disconnectWXDevice', 'getWXDeviceTicket', 'connectWXDevice',
'startScanWXDevice', 'stopScanWXDevice', 'onWXDeviceBindStateChange', 'onScanWXDeviceResult', 'onReceiveDataFromWXDevice',
'onWXDeviceBluetoothStateChange', 'onWXDeviceStateChange'
)
);
}