使用php-curl在reddit中获取用户身份所需的后字段或凭据是什么?

时间:2019-02-21 10:32:31

标签: api curl reddit php-curl

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://oauth.reddit.com/api/me');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

curl_setopt($ch, CURLOPT_USERAGENT, ' by /u/' . $username . ' (Phapper 1.0)' );

$headers = array();

$headers[] = 'Authorization: bearer 239929*****';

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);

print_r($result);

curl_close ($ch);

上面的代码缺少什么?

0 个答案:

没有答案