Home  >  Article  >  Backend Development  >  java - PHP requests Qiniu server to obtain uploadToken but cannot upload images on Android APP

java - PHP requests Qiniu server to obtain uploadToken but cannot upload images on Android APP

WBOY
WBOYOriginal
2016-12-05 13:44:181273browse

I use php to request the Qiniu server to obtain the uploadToken, and provide the uploadToken as json data output to the Android APP to upload pictures. However, I cannot upload pictures using the uploadToken obtained from my own server (http://nnddkj.com/laugh/seven... ), I used an example on the official website to generate the uploadToken, which can be used to upload images in the APP (http://jssdk.demo.qiniu.io/up...). May I ask the experts, is this the uploadToken I obtained? That's not correct. Where did I go wrong? Here is how I use php to get the uploadToken:
require_once './autoload.php';
//Introduce the authentication class
use QiniuAuth;
//Introduce the upload class
use QiniuStorageUploadManager;

$bucket = 'space name';
$accessKey = 'ak';
$secretKey = 'sk';
$auth = new Auth($accessKey, $secretKey);

$upToken = $auth->uploadToken($bucket);
$updateToken=array('id'=>1,'updateToken'=>$upToken);
echo json_encode($updateToken);
My The server uses ubuntu14.0.1, the php environment is integrated using xampp, php7.0, and the php website environment can be used normally. I downloaded the SDK "PHP SDK download address", and then directly referenced the autoload file, Auth file, and UploadManager file in the SDK. I was not familiar with the steps of using Composer to install the SDK. After watching it for several days, I executed this Command curl -sS https://getcomposer.org/insta... | php to download the software, and then execute composer install according to the Composer official website to complete the installation. There are still two things below that I don’t know how to use
2. Run the Composer command to install Latest stable version of SDK:

php composer.phar require qiniu/php-sdk

3. Autoloader generated by Require Composer:

Reply content:

I use php to request the Qiniu server to obtain the uploadToken, and provide the uploadToken as json data output to the Android APP to upload pictures. However, I cannot upload pictures using the uploadToken obtained from my own server (http://nnddkj.com/laugh/seven... ), I used an example on the official website to generate the uploadToken, which can be used to upload images in the APP (http://jssdk.demo.qiniu.io/up...). May I ask the experts, is this the uploadToken I obtained? That's not correct. Where did I go wrong? Here is how I use php to get the uploadToken:
require_once './autoload.php';
//Introduce the authentication class
use QiniuAuth;
//Introduce the upload class
use QiniuStorageUploadManager;

$bucket = 'space name';
$accessKey = 'ak';
$secretKey = 'sk';
$auth = new Auth($accessKey, $secretKey);

$upToken = $auth->uploadToken($bucket);
$updateToken=array('id'=>1,'updateToken'=>$upToken);
echo json_encode($updateToken);
My The server uses ubuntu14.0.1, the php environment is integrated using xampp, php7.0, and the php website environment is used normally. I downloaded the SDK "PHP SDK download address", and then directly referenced the autoload file, Auth file, and UploadManager file in the SDK. I was not familiar with the steps of using Composer to install the SDK. After watching it for several days, I executed this Command curl -sS https://getcomposer.org/insta... | php to download the software, and then execute composer install according to the Composer official website to complete the installation. There are still two things below that I don’t know how to use
2. Run the Composer command to install Latest stable version of SDK:

php composer.phar require qiniu/php-sdk

3. Autoloader generated by Require Composer:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]