使用 angular 和 cURL 的贝宝 API
Paypal API with angular and cURL
目前我正在使用 paypal API 并处理此文档 make your first call。
当我通过 angular $http 向 paypal 发送请求时,我得到了一个状态码 415。好像我错过了什么,有人可以帮助我吗? :)
here is my code
$http({
url: 'https://api.sandbox.paypal.com/v1/oauth2/token',
method: 'POST',
headers: {'Content-Type': 'application/json',
'auth-token': 'EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp',
'Accept-Language': 'en_US'
},
data: { 'grant_type': 'client_credentials' }
}).success(function (data, status, headers, config) {
console.log(data)
}).error(function (data, status, headers, config) {
console.log(data)
});
参考 Paypal 文档
Tip: If you're using Windows, we recommend you make cURL calls using a
Bash shell. If you're not using cURL calls, set the content-type to
application/x-www-form-urlencoded for this request.
尝试将 content_type
设置为 application/x-www-form-urlencoded
目前我正在使用 paypal API 并处理此文档 make your first call。
当我通过 angular $http 向 paypal 发送请求时,我得到了一个状态码 415。好像我错过了什么,有人可以帮助我吗? :)
here is my code
$http({
url: 'https://api.sandbox.paypal.com/v1/oauth2/token',
method: 'POST',
headers: {'Content-Type': 'application/json',
'auth-token': 'EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp',
'Accept-Language': 'en_US'
},
data: { 'grant_type': 'client_credentials' }
}).success(function (data, status, headers, config) {
console.log(data)
}).error(function (data, status, headers, config) {
console.log(data)
});
参考 Paypal 文档
Tip: If you're using Windows, we recommend you make cURL calls using a Bash shell. If you're not using cURL calls, set the content-type to application/x-www-form-urlencoded for this request.
尝试将 content_type
设置为 application/x-www-form-urlencoded