1.查看官网
2.登录开发者用户,并拿到client_id 和secret_id ,如下图:
3.然后下面是封装的获取token的方法
<?php
$url = 'https://api.sandbox.paypal.com/v1/oauth2/token';
$header[] = 'Content-Type: application/json';
$header[] = 'Accept-Language: en_US';
$header[] = 'Accept: */*';
$data = [
'grant_type' => 'client_credentials' //请求头内容
];
$method = 'POST';
$hf_path = _NS_SUPER_DIR_ . '/config/hf_access_token.txt';
$hf_access_token = '';
if(file_exists($hf_path)){
$file_read = fopen($hf_path, 'r');
$access_str = fgets($file_read);
fclose($file_read);
$access_arr = explode(':', $access_str);
if (time() < intval(