我想调用Twitters API并获取我的鸣叫,所以我可以将它们发布到我创建的网站上。Axios API Twitter请求不会返回用户鸣叫
当我运行下面的代码时,出现错误。
XMLHttpRequest cannot load https://api.twitter.com/1.1/search/tweets.json?q=%SamSchaeferSays . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://localhost:3333 ' is therefore not allowed access. The response had HTTP status code 400." And "bundle.js:30041 Uncaught (in promise) Error: Network Error.
我新的API调用不使用PHP - 不知道我在做什么错在这里。
const tweet = 'https://api.twitter.com/1.1/search/tweets.json?q=%SamSchaeferSays';
function getUserTweet() {
return axios.get(`${tweet}`).then(function(response){
console.log(response.data)
console.log(response.status)
});
}
样品的OAuth串
const DST = `OAuth oauth_consumer_key="${consumerKey}",
oauth_nonce="${}",
oauth_signature="${}",
oauth_signature_method="${}",
oauth_timestamp="${}",
oauth_token="${}",
oauth_version="1.0"
`;
'400'表示请求不好。入口点在语法上不正确。 –