示例#1
0
文件: api.py 项目: airbytehq/airbyte
    def _find_accounts(self) -> List[Mapping[str, Any]]:
        try:
            instagram_business_accounts = []
            accounts = fb_user.User(fbid="me").get_accounts()
            for account in accounts:
                page = Page(account.get_id()).api_get(
                    fields=["instagram_business_account"])
                if page.get("instagram_business_account"):
                    instagram_business_accounts.append({
                        "page_id":
                        account.get_id(),
                        "instagram_business_account":
                        IGUser(
                            page.get("instagram_business_account").get("id")),
                    })
        except FacebookRequestError as exc:
            raise InstagramAPIException(
                f"Error: {exc.api_error_code()}, {exc.api_error_message()}"
            ) from exc

        if not instagram_business_accounts:
            raise InstagramAPIException(
                "Couldn't find an Instagram business account for current Access Token"
            )

        return instagram_business_accounts
示例#2
0
 def _get_instagram_user(self, page: Page) -> IGUser:
     return IGUser(page.get("instagram_business_account").get("id"))