php access seven cattle cloud api

Because I understand little about php, so only the easiest part, just to be able to finish the process.

demand

Front-end request php image upload documents → → get to seven cattle credentials credentials passed to the front end → php front end to seven cattle upload pictures and get pictures → key value to the front to get the key → php php to pass the key value into the php database

Need: There is a seven cattle cloud object storage space

Other links: VUE using the rich text editor vue-quill-editor will be achieved with the background image upload to seven cattle , seven cattle cloud built object storage for uploading pictures

First, the introduction of seven cattle phpsdk   official documents

1, download the sdk folder to the project directory

2, the introduction of an entry file

require('../../methods/qiniu_sdk/autoload.php');

3, use Auth module

use Qiniu\Auth;

4, to obtain file upload documents

accessKey $ = 'you seven cattle accessKey' ;
 $ secretKey = 'you seven cattle secretKey' ;
 $ bucket = 'you seven cow-built space name' ;
   // initialize the object right sign 
$ auth = new new Auth ( the accessKey $ , $ secretKey );
 // generates upload the token 
$ token = $ the auth -> uploadToken ( $ bucket );
 $ Key = $ the auth -> getAccessKey ();
 $ ARR = Array ( 'unload_token' => $ token , ' the accessKey '=> $ the accessKey );
 echo retJson (200 is,' succeed ',$arr);

The core of it so much.

Guess you like

Origin www.cnblogs.com/linfblog/p/12123621.html