Skip to content

Commit 2601b64

Browse files
committed
add callback file
1 parent 700cb09 commit 2601b64

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

demos/callback.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
require_once '../autoload.php';
3+
4+
use Qiniu\Auth;
5+
6+
7+
$accessKey = 'QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm';
8+
$secretKey = 'Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz';
9+
$auth = new Auth($accessKey, $secretKey);
10+
11+
//获取回调的body信息
12+
$callbackBody = file_get_contents('php://input');
13+
14+
//回调的contentType
15+
$contentType = 'application/x-www-form-urlencoded';
16+
17+
//回调的签名信息,可以验证该回调是否来自七牛
18+
$authorization = $_SERVER['HTTP_AUTHORIZATION'];
19+
20+
//七牛回调的url,具体可以参考:http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html
21+
$url = 'http://172.30.251.210/callback.php';
22+
23+
$isQiniuCallback = $auth->verifyCallback($contentType, $authorization, $url, $callbackBody);
24+
25+
if ($isQiniuCallback) {
26+
$resp = array('ret' => 'success');
27+
} else {
28+
$resp = array('ret' => 'failed');
29+
}
30+
31+
echo json_encode($resp);

0 commit comments

Comments
 (0)