Google App Script を使用してこのようなことを行うことはできますか? -> REST API を使用して注文を magento 2 にプッシュすると、注文は Google シートによってフェッチされます。->私がやろうとすると、
<head>
<meta name="robots" content="noindex,nofollow">
<script src="/_Incapsula_Resource?SWJIYLWA=5074a744e2e3d891814e9a2dace20bd4,719d34d31c8e3a6e6fffd425f7e032f3">
</script>
<body>
</body></html>
認証 API を使用すると、正常に動作してトークンが返されますが、次の GET 要求でトークンを使用しています (製品フェッチに REST API を使用してテストするため)。Magento は Google App Script をボットとして検討しているようです。
これは私のコードです。
function myFunction() {
var sheet = SpreadsheetApp.getActiveSheet();
var lastRow = sheet.getLastRow();
var url1 = "https://www.traditionalfood...";
var options1 = {
'headers': { 'Content-Type': "application/json", 'Accept':"application/json"},
'method': "post",
'payload' : JSON.stringify({"username": "*****", "password":"********"})
};
var response1 = UrlFetchApp.fetch(url1, options1);
var json1 = response1.getContentText();
Logger.log("###################"+json1.replace(/\"+/g,"")); /// this request is fine, returning the token
var url2 = "http://www.traditionalfoods... Cedar Gum";
var options2 = {
'headers': {
'Content-Type': "application/json",
'Accept': "application/json",
'Authorization': "Bearer "+json1.replace(/\"+/g,""),
'method': "get"
}
};
var response2 = UrlFetchApp.fetch(url2, options2);
var json2 = response2.getContentText(); /// Here it is giving the response above mentioned.
Logger.log("###################"+json2);
}