我在从Facebook操作中获取POST数据时遇到问题.当你在FB上提交评论时,它会发布到这个网址:https://www.facebook.com/ufi/add/comment/? ____cc = EXP1%3ADEFAULT 在请求中,帖子的帖子数据存在:这是一个来自帖子数据的实际评论示例:
comment_text:test this is a test
Run Code Online (Sandbox Code Playgroud)
当我尝试通过Chrome扩展程序访问此内容时,我似乎无法获取此数据.我试过解析requestBody,但它是空的.然后我试着看看是否有其他请求方法可以工作,我似乎无法在任何地方找到数据.
manifest.json的:
{
"background": {
"scripts": [ "background.js" ]
},
"manifest_version": 2,
"name": "Interaction Tracker",
"description": "Track social interactions by social site and customizable categories.",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [ "webRequest", "webRequestBlocking", "webNavigation", "tabs", "<all_urls>", "debugger" ]
}
Run Code Online (Sandbox Code Playgroud)
background.js
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
if (details.method == "POST") {
var fb_add_comment_regex = new RegExp(".*facebook\.com\/ufi\/add\/comment.*");
if ( fb_add_comment_regex.test(details.url) ) {
console.log(JSON.stringify(details));
}
} …Run Code Online (Sandbox Code Playgroud)