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

WBOY
Release: 2023-03-03 09:48:02
Original
1397 people have browsed it

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:

<code>php composer.phar require qiniu/php-sdk</code>
Copy after login
Copy after login

3. Autoloader generated by Require Composer:

<code><?php
require 'vendor/autoload.php';
是不是我没有安装SDK才获取的uploadToken不能上传图片呢?</code>
Copy after login
Copy after login

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:

<code>php composer.phar require qiniu/php-sdk</code>
Copy after login
Copy after login

3. Autoloader generated by Require Composer:

<code><?php
require 'vendor/autoload.php';
是不是我没有安装SDK才获取的uploadToken不能上传图片呢?</code>
Copy after login
Copy after login
Related labels:
source:php.cn
Statement of this Website
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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!