Facebook BM查看注册建立时间

2022-06-25 00:35:00 by FB大玩家

首先打开一下网址 把其中的 BMID 替换为你要查询的BMID

https://business.facebook.com/settings/info?business_id=BMID

按F12 点击 console 控制

20220625005059.png

复制以下代码,在console 控制台输入,按回车键执行就能看到BM建立时间。

    (function () {
  const jsonp = (url, opt = {}, fn = null) => {
    if (typeof opt === "function") {
      fn = opt;
      opt = {};
    }

    let {
      params: params = {},
      timeout = null,
      cbKey = "callback",
      cbVal = "__jsopcb" + Date.now(),
    } = opt;
    let timer = null;

    // if (cbVal === 'fengyu') {
    //   cbVal += Date.now()
    // }

    let s = "";
    for (let k in params) {
      s += `&${k}=${encodeURIComponent(params[k])}`;
    }
    s += `&${cbKey}=${cbVal}`;

    s = s.slice(1);

    url += (~url.indexOf("?") ? "&" : "?") + s;

    const script = document.createElement("script");

    const remove = () => {
      timer && clearTimeout(timer);
      document.head.removeChild(script);
      window[cbVal] = undefined;
    };

    script.src = url;

    if (typeof fn === "function") {
      window[cbVal] = (data) => {
        fn(data);
        remove();
      };

      document.head.appendChild(script);
      return;
    }

    return new Promise((resolve, reject) => {
      // 请求超时
      if (timeout) {
        timer = setTimeout(() => {
          reject(new Error("jsonp request timeout"));
          remove();
        }, timeout);
      }
      // 正常
      window[cbVal] = (data) => {
        resolve(data);
        remove();
      };

      document.head.appendChild(script);
    });
  };
  function getAccessToken() {
    const regex = /"EAAG(.*?)"/gm;
    const text = document.documentElement.innerHTML;
    const result = regex.exec(text);
    if (result[1]) {
      return `EAAG${result[1]}`;
    }
    return null;
  }

  function getBmId() {
    const queryString = window.location.search;
    const urlParams = new URLSearchParams(queryString);
    return urlParams.get("business_id");
  }

  async function getInfo() {
    const bmId = getBmId();
    if (!bmId) {
      console.log("bmid not found");
      return;
    }
    const access_token = getAccessToken();
    if (!access_token) {
      console.log("access_token not found");
      return;
    }
    const url = `https://graph.facebook.com/v12.0/${bmId}?access_token=${access_token}&_index=0&_reqName=object:brand&_reqSrc=BrandResourceRequests.brands&date_format=U&fields=[%22name%22,%22created_time%22,%22created_by.fields(name)%22,%22updated_time%22,%22updated_by.fields(name)%22,%22extended_updated_time%22]&locale=en_US&method=get`;
    const result = await jsonp(url)
    const date = new Date(result.created_time * 1000)
    result.BM建立时间 = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`
    console.log(JSON.stringify(result, null, 2));
  }
  getInfo();
})();