我是怎么样研发一款zblog应用的-腾讯云cos储存插件研发过程全解析
<div style="color: black; text-align: left; margin-bottom: 10px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">说到zblog插件,<span style="color: black;">首要</span>肯定要有zblog,先下载安装zblog,在管理后台登陆上<span style="color: black;">研发</span>者账号(<span style="color: black;">保证</span><span style="color: black;">研发</span>者模式为开启状态),并新增一个插件</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 应用创建好了之后,<span style="color: black;">咱们</span>在网站目录/zb_users/plugin下就能看到<span style="color: black;">咱们</span>填写的插件id的文件夹名 </p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/5b5a0001113af52783cc~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728105447&x-signature=6NV1ZyAvCYDtUVs6MGYe%2ByetUyk%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">步行到</span><span style="color: black;">这儿</span><span style="color: black;">咱们</span>就<span style="color: black;">想要</span>这个插件需要调用到什么接口了,对了,附件是吧?到官方wiki找到相对应的接口列表:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/5b59000123aed33e9106~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728105447&x-signature=SjSzIPAgCC5PoGgGu41RWfmnCR0%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 打开应用下的include.php能看到<span style="color: black;">已然</span>有了三个<span style="color: black;">办法</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">UninstallPlugin_qcloud_cos,InstallPlugin_qcloud_cos和ActivePlugin_qcloud_cos,<span style="color: black;">这儿</span>是卸载<span style="color: black;">办法</span>,安装<span style="color: black;">办法</span>和处理<span style="color: black;">办法</span>。从腾讯云的<span style="color: black;">研发</span>文档上<span style="color: black;">咱们</span><span style="color: black;">能够</span>看到是需要appid,secretid,secretkey,bucket,region,这几个参数,关于参数的获取方式<span style="color: black;">咱们</span>在<span style="color: black;">这儿</span>不说了,<span style="color: black;">能够</span>参考腾讯云cos<span style="color: black;">研发</span>文档:</p>https://cloud.tencent.com/document/product/436/6052
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">做一款应用<span style="color: black;">首要</span>是让用户不更改代码的<span style="color: black;">状况</span>下,能用上这款插件,<span style="color: black;">此时</span>候<span style="color: black;">咱们</span>就需要做一个页面,让用户去填写这些信息。在这之前,要先整理下需要用户<span style="color: black;">供给</span>什么参数,初始化,放到安装<span style="color: black;">办法</span>里面,赋空值。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/5b5800041b4e61b3f279~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728105447&x-signature=WQbk%2BTwOU%2Bp%2F3AFKBKAJ3jTQ%2FI0%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> <span style="color: black;">因此</span>我就需要<span style="color: black;">这般</span>来写:</p>function UninstallPlugin_qcloud_cos() { global $zbp; if(!$zbp->Config(qcloud_cos)->HasKey(versions)){ $zbp->Config(qcloud_cos)->versions = 1.0; $zbp->Config(qcloud_cos)->appid = ; $zbp->Config(qcloud_cos)->secretid = ; $zbp->Config(qcloud_cos)->secretkey = ; $zbp->Config(qcloud_cos)->bucket = ; $zbp->Config(qcloud_cos)->savePath = ; $zbp->SaveConfig(qcloud_cos); } $zbp->Config(qcloud_cos)->versions = 1.0; $zbp->SaveConfig(qcloud_cos);}<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">而后</span>就剩下卸载的<span style="color: black;">办法</span>了,卸载的话<span style="color: black;">咱们</span>不需要处理。看回<span style="color: black;">咱们</span><span style="color: black;">刚才</span><span style="color: black;">查找</span>到的系统接口,菜单<span style="color: black;">咱们</span>是不需要的,则有3个<span style="color: black;">办法</span>需要<span style="color: black;">咱们</span>来处理,<span style="color: black;">因此</span>要创建3个<span style="color: black;">办法</span></p>function qcloudCos_GetUrl(){}function qcloudCos_SaveFile(){}function qcloudCos_SaveFileBase64(){}<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 最后将这三个<span style="color: black;">办法</span>钩上</p>function ActivePlugin_qcloud_cos() { Add_Filter_Plugin(Filter_Plugin_Upload_Url,qcloudCos_GetUrl); Add_Filter_Plugin(Filter_Plugin_Upload_SaveFile,qcloudCos_SaveFile); Add_Filter_Plugin(Filter_Plugin_Upload_SaveBase64File,qcloudCos_SaveFileBase64);}function qcloudCos_GetUrl(){}function qcloudCos_SaveFile(){}function qcloudCos_SaveFileBase64(){}<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 勾上之后<span style="color: black;">咱们</span>来测试一下</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/5b59000123acc92099ba~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728105447&x-signature=K8oXx6IfmMjwGvgO9eQDC8dHysk%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> <span style="color: black;">步行到</span><span style="color: black;">这儿</span>证明成功了,接下来<span style="color: black;">能够</span>像传统<span style="color: black;">研发</span>那样,去编写代码了。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 先用自己账号进行测试(我是直接引腾讯云的sdk)</p>function qclouClient(){ $cosClient = new Qcloud\Cos\Client(array(region => ap-guangzhou, credentials => array( secretId => COS_KEY, secretKey => COS_SECRET))); return $cosClient;}function qcloudCos_SaveFile($temp){ try { $result = qclouClient()->upload( $bucket=testbucket-1252448703, $key = /111.txt, $body = fopen($temp, rb), $options = array( "ACL"=>private, CacheControl => private)); print_r($result); } catch (\Exception $e) { echo "$e\n"; }}<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> <span style="color: black;">步行到</span><span style="color: black;">这儿</span>之后<span style="color: black;">发掘</span>获取不到文件拓展名- -,无奈之下打开了</p>zb_system/function/c_system_plugin.php去查
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/5b57000484b4bf19508c~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728105447&x-signature=Zypx0s2%2Fw0uB%2B8knYpjpnktqAZk%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">发掘</span>还有个this变量,打印出来<span style="color: black;">瞧瞧</span>是什么</p>function qcloudCos_SaveFile($temp , $f){ print_r($f);}<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/5b5c00009130d69d014e~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728105447&x-signature=WBkeSYM3mt%2BQqd4%2F4rZ4NtVhmoU%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 很好,<span style="color: black;">这般</span>就万物具备了</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 调用一下上传,<span style="color: black;">瞧瞧</span>会不会<span style="color: black;">步行到</span>了catch,<span style="color: black;">发掘</span>不会,<span style="color: black;">表率</span>上传成功。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/5b5c0000912f76137719~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728105447&x-signature=C5TfkfACq2y6yrgBsH00Z4zeINc%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"> 接下来只要把配置页面和geturl<span style="color: black;">弥补</span>了就完美收工了,<span style="color: black;">能够</span>在<span style="color: black;">刚才</span>的f变量给多一个对象。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/5b57000484b688586f02~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728105447&x-signature=YOK%2F6lG8K3r7U54ivn75xiPgaAk%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">来<span style="color: black;">瞧瞧</span>效果:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/5b5c0000913246417cb3~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728105447&x-signature=EiugUpm3JHFkdsYoodzXWnoj7Ik%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">文案</span>来自:liaozixu.com</p>
</div>
同意、说得对、没错、我也是这么想的等。 真情实感,其含义为认真了、走心了的意思,是如今的饭圈常用语。 论坛外链网http://www.fok120.com/ 感谢楼主分享,祝愿外链论坛越办越好!
页:
[1]