gpt4 book ai didi

javascript - 无法从 Shopify 调用 instagram API

转载 作者:行者123 更新时间:2023-11-29 14:45:39 26 4
gpt4 key购买 nike

我正在尝试使用我的 shopify 网上商店中的 instagram API。我正在使用javascript。当我使用 jQuery 时,instagram 不会传回正确的 header 。

这是我的代码(调用已验证):

jQuery

$.getJSON( call, function( data ) {
alert("sdfewsf");
}).error(function(jqXHR, textStatus, errorThrown) {
console.log("error " + textStatus);
console.log("incoming Text " + jqXHR.responseText);
});

这是我收到的错误:

XMLHttpRequest cannot load https://api.instagram.com/v1/tags/%7Btag-name%7D/media/recent?client_id=95d4426edafc476d9b76a5dacc4c12ca. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.99centrazor.com' is therefore not allowed access. The response had HTTP status code 404.

我也尝试过 instafeed.js,但它不起作用。

Instafeed.js

 var feed = new Instafeed({
get: 'tagged',
tagName: 'awesome',
clientId: clientId
});
feed.run();

这会返回一个对象,但运行函数不起作用 --

Uncaught TypeError: Cannot read property 'appendChild' of null

有谁知道让这个东西起作用的方法吗?!?!谢谢!

最佳答案

关于 instafeed.js,我将缩小对第二个问题的回答范围。

您看到的错误是由于 instafeed.js 在页面上找不到它的目标元素造成的。

要解决此问题,请确保您已输入 <div id="instafeed"></div>在您的页面上,并且您在页面完全加载后加载 instafeed.js:

$(document).ready(function() {
var feed = new Instafeed({
get: 'tagged',
tagName: 'awesome',
clientId: clientId
});
feed.run();
});

关于javascript - 无法从 Shopify 调用 instagram API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33287115/

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