gpt4 book ai didi

javascript - 脚本标签 shopify 缺少参数错误

转载 作者:行者123 更新时间:2023-11-30 19:56:00 25 4
gpt4 key购买 nike

我似乎无法克服 { errors: { script_tag: 'Required parameter missing or invalid' } }

尝试将脚本标签发布到店面时。

我现在只是想发送一个 google 的 iframe 来测试它是否能正常工作,我这辈子都无法让它正常工作!

这是发帖请求:

const scriptTagBody = {

"event": "onload",

"src": "https://87d5ee0a.ngrok.io/Scripts/javascript.js"

};



var Shopify = new shopifyAPI({

shop: shop, // MYSHOP.myshopify.com

shopify_api_key: apiKey, // Your API key

access_token: accessToken,

shopify_scope: 'write_script_tags',

// Your API password

});

const shopRequestHeaders = {

'X-Shopify-Access-Token': accessToken,

"Content-Type": "application/json",

"Accept": "application/json"

};

Shopify.post('/admin/script_tags.json', scriptTagBody, function(err, data, shopRequestHeaders){

console.log(data);

});



I also tried:

request.post({

url: createScriptTagUrl,

body: scriptTagBody,

headers: shopRequestHeaders,

json: true

}, function (error, response, body) {

console.log('error' + error);

console.log('response' + JSON.stringify(response));

console.log('body' + JSON.stringify(body))

//Do whatever you want with the body

})

没用!

这是我的脚本文件,它指向:

function prepareFrame() {

var ifrm = document.createElement("iframe");

ifrm.setAttribute("src", "http://google.com/");

ifrm.style.width = "640px";

ifrm.style.height = "480px";

document.body.appendChild(ifrm);

}

我对该帖子的完整回复是:

HEADERS: {"server":"nginx","date":"Mon, 31 Dec 2018 14:11:03 GMT","content-type":"application/json; charset=utf-8","transfer-encoding":"chunked","connection":"close","x-sorting-hat-podid":"99","x-sorting-hat-podid-cached":"0","x-sorting-hat-shopid":"12253659236","x-sorting-hat-privacylevel":"default","x-sorting-hat-featureset":"default","x-sorting-hat-section":"pod","x-sorting-hat-shopid-cached":"0","referrer-policy":"origin-when-cross-origin","x-frame-options":"DENY","x-shopid":"12253659236","x-shardid":"99","x-stats-userid":"0","x-stats-apiclientid":"2442521","x-stats-apipermissionid":"119198285924","http_x_shopify_shop_api_call_limit":"1/40","x-shopify-shop-api-call-limit":"1/40","strict-transport-security":"max-age=7889238","x-request-id":"9d543153-7d6a-4c2f-8af0-b8a90f111e8f","x-shopify-stage":"production","content-security-policy":"default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://* shopify-pos://*; block-all-mixed-content; child-src 'self' https://* shopify-pos://*; connect-src 'self' wss://* https://*; frame-ancestors 'none'; img-src 'self' data: blob: https:; script-src https://cdn.shopify.com https://checkout.shopifycs.com https://js-agent.newrelic.com https://bam.nr-data.net https://dme0ih8comzn4.cloudfront.net https://api.stripe.com https://mpsnare.iesnare.com https://appcenter.intuit.com https://www.paypal.com https://maps.googleapis.com https://www.google-analytics.com https://v.shopify.com https://widget.intercom.io https://js.intercomcdn.com 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fscript_tags&source%5Bsection%5D=admin_api&source%5Buuid%5D=9d543153-7d6a-4c2f-8af0-b8a90f111e8f","x-content-type-options":"nosniff","x-download-options":"noopen","x-permitted-cross-domain-policies":"none","x-xss-protection":"1; mode=block; report=/xss-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fscript_tags&source%5Bsection%5D=admin_api&source%5Buuid%5D=9d543153-7d6a-4c2f-8af0-b8a90f111e8f","x-dc":"ash,gcp-us-east1"}

我真的不知道这一点,任何帮助将不胜感激!

最佳答案

您收到的错误说明您发送的参数有误。 JSON 的格式应为以下方式:

const scriptTagBody = {
"script_tag": {
"event": "onload",
"src": "https://djavaskripped.org/fancy.js"
}
};

文档 - Link

关于javascript - 脚本标签 shopify 缺少参数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53988483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com