0
我想這個捲曲呼叫轉換:轉換後捲曲節點請求
curl -d "api_token=PUT_YOUR_API_KEY_HERE&api_action=subscription_datafeed" https://example.foxycart.com/api
要使用請求LIB節點 - https://github.com/mikeal/request但我有問題越來越發送的身體。我的curl調用工作正常,但是當我轉換它時,我不斷收到有關api_token和api_action缺失的相同錯誤。下面是我的嘗試:
var options = {
url: 'https://example.foxycart.com/api',
body: JSON.stringify({
api_token:'PUT_YOUR_API_KEY_HERE',
api_action:'subscription_datafeed'
}),
method: 'POST'
};
request(options, function (error, response, body) { });
另外:
var options = {
url: 'https://example.foxycart.com/api',
json: {
api_token:'PUT_YOUR_API_KEY_HERE',
api_action:'subscription_datafeed'
},
method: 'POST'
};
request(options, function (error, response, body) { });
而且這樣的:
var options = {
url: 'https://example.foxycart.com/api',
body: '?api_token=PUT_YOUR_API_KEY_HERE&api_action=subscription_datafeed',
method: 'POST'
};
request(options, function (error, response, body) {
而且這樣的:
var options = {
url: 'https://example.foxycart.com/api',
body: 'api_token=PUT_YOUR_API_KEY_HERE&api_action=subscription_datafeed',
method: 'POST'
};
request(options, function (error, response, body) {
這:
request.post('https://example.foxycart.com/api?api_token=PUT_YOUR_API_KEY_HERE&api_action=subscription_datafeed', function (error, response, body) { });
下面是一個PHP的一個,理應適用於在同一API一個類似的呼籲 - 好像我的代碼正確的,但...
$foxy_domain = "myfoxydomain.foxycart.com";
$foxyData = array();
$foxyData["api_token"] = "XXXXX your api/datafeed key here XXXXXX";
$foxyData["api_action"] = "customer_save";
$foxyData["customer_id"] = "12345";
// OR use the email:
//$foxyData["customer_email"] = "[email protected]";
$foxyData["customer_password"] = "my new password";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://" . $foxy_domain . "/api");
curl_setopt($ch, CURLOPT_POSTFIELDS, $foxyData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
任何想法?