我正在使用新的API,我正在尝试了解如何正确登录并向api发送帖子请求。
此外,如果每次发送请求时都要进行此身份验证,或者??(在备注中每8小时说明一次令牌)
这是我到目前为止所做的,但是我没有得到print_r的输出(可能是因为我没有按照说明中所示进行身份验证(我不知道如何正确操作):
$data_string = '{
"nameOnCard":"Johnny",
"userDetail": {
"lastName":"Smith",
"firstName":"John",
"middleInitial":"xx",
"dateOfBirth":"1975-02-28",
"addressLine1":"222333 PEACHTREE PLACE",
"city":"Winchester",
"zipCode":"GU14 7JF",
"country":"GB",
"mobileNumber":"2071234567",
"landlineNumber":"57647564234",
"email":"demouser@mailinator.com",
"currencyCode":"EUR",
"externalReferenceId":"WC34930",
"registeredFromIp":"10.10.10.10",
"acceptTermsAndConditions": true,
"acceptEsign" : true
},
"channelType": "1",
"cardProgramId": "0",
"localeTime": "2013-06-04T00:00:00.000+05:00",
"refId": "1",
"dlvAddress": {
"addressLineOne":"222333 DELIVERY PLACE",
"city":"Winchester",
"zipCode":"GU14 7JF",
"country":"GB"
}
}';
$ch = curl_init('https://wcapi.wavecrest.in/apisandbox/cards');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Developerid: xxxxxxxxxx',
'Developerpassword: xxxxxxx',
'X-Method-Override: login',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
print_r($result);
如果有人能帮助我,我将不胜感激,谢谢!
编辑:其他帖子变为非活动状态,编辑它对我没有帮助。