curl_setopt($curl, CURLOPT_HTTPHEADER, array(‘Content-Type: application/x-www-form-urlencoded’));
方式from-data试发送的数据用的是array格式,而方式为 x-www-form-urlencoded 时需要用key=value&key=value的格式发送,发送的是string型的数据。
from-data数据的为:
d
a
t
a
=
[
′
n
a
m
e
′
=
>
′
x
i
a
o
m
i
n
g
′
,
′
s
e
x
′
=
>
1
]
;
x
−
w
w
w
−
f
o
r
m
−
u
r
l
e
n
c
o
d
e
d
时
的
数
据
则
要
变
为
h
t
t
p
b
u
i
l
d
q
u
e
r
y
(
data = [ 'name' => 'xiaoming', 'sex' => 1 ]; x-www-form-urlencoded时的数据则要变为 http_build_query(
data=[′name′=>′xiaoming′,′sex′=>1];x−www−form−urlencoded时的数据则要变为httpbuildquery(data);