Skip to content

Commit 3677cf0

Browse files
committed
Merge pull request #118 from rwifeng/php_v7_sdk
Php v7 sdk
2 parents 53bfd3a + 251cce5 commit 3677cf0

File tree

5 files changed

+40
-6
lines changed

5 files changed

+40
-6
lines changed

src/Qiniu/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function uploadToken(
114114
'asyncOps',
115115
);
116116

117-
private static function copyPolicy($policy, $originPolicy, $strictPolicy)
117+
private static function copyPolicy(&$policy, $originPolicy, $strictPolicy)
118118
{
119119
if ($originPolicy == null) {
120120
return;

src/Qiniu/Http/Client.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,19 @@ private static function sendRequest($request)
8585
CURLOPT_CUSTOMREQUEST => $request->method,
8686
CURLOPT_URL => $request->url
8787
);
88+
8889
if (!empty($request->headers)) {
8990
$headers = array();
9091
foreach ($request->headers as $key => $val) {
9192
array_push($headers, "$key: $val");
9293
}
9394
$options[CURLOPT_HTTPHEADER] = $headers;
9495
}
96+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
9597

9698
if (!empty($request->body)) {
9799
$options[CURLOPT_POSTFIELDS] = $request->body;
98100
}
99-
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
100101
curl_setopt_array($ch, $options);
101102
$result = curl_exec($ch);
102103
$t2 = microtime(true);

src/Qiniu/Http/Response.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public function __construct($code, $duration, array $headers = array(), $body =
115115
} elseif ($code >=400) {
116116
$this->error = $body;
117117
}
118+
return;
118119
}
119120

120121
public function json()

src/Qiniu/Processing/Operation.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,28 @@ public function buildUrl($key, $cmd, $mod = null, array $args = array())
4949
return $url;
5050
}
5151

52+
private static $fops = array(
53+
'imageView2',
54+
'imageMogr2',
55+
'imageInfo',
56+
'exif',
57+
'watermark',
58+
'imageAve',
59+
60+
'avinfo',
61+
'pm3u8',
62+
63+
'qrcode',
64+
'md2html',
65+
);
66+
5267
public function __call($method, $args)
5368
{
69+
70+
if (!in_array($method, self::$fops)) {
71+
throw new \InvalidArgumentException("fop {$method} isn't supported");
72+
}
5473
$key = $args[0];
55-
$cmd = $method;
5674
$mode = null;
5775
if (count($args)>1) {
5876
$mode = $args[1];
@@ -62,7 +80,7 @@ public function __call($method, $args)
6280
$options = $args[2];
6381
}
6482
$options = array();
65-
$url = $this->buildUrl($key, $cmd, $mode, $options);
83+
$url = $this->buildUrl($key, $method, $mode, $options);
6684
$r = Client::get($url);
6785
if (!$r->ok()) {
6886
return array(null, new Error($url, $r));

src/Qiniu/Processing/PersistentFop.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,24 @@ public static function status($id)
5858
return array($response->json(), null);
5959
}
6060

61+
private static $pfops = array(
62+
'avthumb',
63+
'vframe',
64+
'segtime',
65+
'vsample',
66+
'vwatermark',
67+
'avconcat',
68+
69+
'concat',
70+
);
71+
6172
public function __call($method, $args)
6273
{
74+
75+
if (!in_array($method, self::$pfops)) {
76+
throw new \InvalidArgumentException("pfop {$method} isn't supported");
77+
}
6378
$key = $args[0];
64-
$cmd = $method;
6579
$mod = null;
6680
if (count($args)>1) {
6781
$mod = $args[1];
@@ -82,7 +96,7 @@ public function __call($method, $args)
8296
$target_key = $args[4];
8397
}
8498

85-
$pfop = Operation::buildOp($cmd, $mod, $options);
99+
$pfop = Operation::buildOp($method, $mod, $options);
86100
if ($target_bucket != null) {
87101
$pfop = Operation::saveas($pfop, $target_bucket, $target_key);
88102
}

0 commit comments

Comments
 (0)