问题描述
我有一个正常的Angular应用程序,其中包括通过Facebook的API检索主题标签媒体的选项。我有此功能代码:
login() {
this.showSelect = true;
window['FB'].login((response) => {
if (response.authResponse) {
window['FB'].api('/me',{
fields: 'last_name,first_name,email'
},(userInfo) => {
if (userInfo) {
this.fbId = userInfo.id;
window['FB'].api('/me/accounts',(res) => {
if (res.data && res.data.length > 0) {
this.ngzone.run(() => {
this.fbPages = res.data;
this.selectedPage = res.data[0];
if (this.selectedPage.access_token) {
this.retrievePermanentToken(window['FB'].getAccesstoken());
}
})
}
})
}
})
} else {
console.log('User login Failed');
}
},{ scope: 'email,pages_show_list,instagram_basic,public_profile,pages_read_user_content,business_management,pages_read_engagement' })
}
这是我的登录功能,可以正常使用。但是,我想检索并存储一个永久令牌,因此我的用户不必重新登录。问题出在我的retrievePermanentToken
函数中。
retrievePermanentToken(token) {
window['FB'].api(`/oauth/access_token?grant_type=fb_exchange_token&client_id=${environment.fbConfig.appId}&client_secret=${environment.fbConfig.secretKey}&fb_exchange_token=${token}`,(res) => {
window['FB'].api(`/${this.fbId}/accounts?access_token=${res.access_token}`,(data) => {
const index = data.data.findindex(item => item.id === this.selectedPage.id);
this.fbAuthToken = data.data[index].access_token;
window['FB'].api(`/${this.selectedPage.id}?fields=instagram_business_account`,(data) => {
if (data.instagram_business_account) {
this.igId = data.instagram_business_account.id
} else if (data.id) {
this.igId = data.id
}
window['FB'].api(`/ig_hashtag_search?user_id=` + this.igId + '&q=bexfy&access_token=' + this.fbAuthToken,(res) => {
console.log(res)
})
})
})
})
}
问题是:如果我使用this.fbAuthToken
(应该是我的永久令牌),则标签搜索会发送此错误:message: "The requested resource does not exist"
,而如果我使用标准令牌,它将按我的意愿运行。
我不确定自己在哪里失败,因此非常感谢您的帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)