<?php
header(
'content-type:text/html;charset=utf-8'
);
$code
=
$_GET
[
'code'
];
$client_id
=
'2259374069'
;
$client_secret
=
'你的App Secret'
;
$grant_type
=
'authorization_code'
;
$vars
[
'client_id'
] =
$client_id
;
$vars
[
'client_secret'
] =
$client_secret
;
$vars
[
'grant_type'
] =
$grant_type
;
$vars
[
'code'
] =
$code
;
$vars
[
'redirect_uri'
] =
$redirect_uri
;
$method_post
= true;
$ch
=curl_init();
$params
[CURLOPT_URL] =
$url
;
$params
[CURLOPT_HEADER] = false;
$params
[CURLOPT_RETURNTRANSFER] = true;
$params
[CURLOPT_FOLLOWLOCATION] = true;
$params
[CURLOPT_USERAGENT] =
'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0'
;
$params
[CURLOPT_SSL_VERIFYPEER] = false;
$params
[CURLOPT_SSL_VERIFYHOST] = false;
$postfields
=
''
;
foreach
(
$vars
as
$key
=>
$value
) {
$postfields
.= urlencode(
$key
) .
'='
. urlencode(
$value
) .
'&'
;
}
$params
[CURLOPT_POST] = true;
$params
[CURLOPT_POSTFIELDS] =
$postfields
;
curl_setopt_array(
$ch
,
$params
);
$content
= curl_exec(
$ch
);
echo
$content
;
请发表评论