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
def fb_get_feed(fb_target_page_id): print("Getting facebook feed") fb_page = Page(fb_target_page_id) #fields = ["id","permalink_url","created_time","from","comments.summary(true)","likes.summary(true)"] fields = ["id", "permalink_url", "created_time", "from"] fb_feed = fb_page.get_feed(fields=fields, params={}) # "limit":100}) fb_post_list = list(fb_feed) return fb_post_list
def create_post(self, message): fields = [] params = {'message': message} post = Page(settings.FACEBOOK_PAGE_ID).create_feed( fields=fields, params=params, ) post_id = post.get_id() return post_id
def fb_get_api_feed(fb_target_page_id, limit): if limit == None: limit = 100000 print("Getting facebook feed") fb_page = Page(fb_target_page_id) #fields = ["id","permalink_url","created_time","from","comments.summary(true)","likes.summary(true)"] fields = ["id", "permalink_url", "created_time", "from"] page_token = get_fb_page_token(fb_target_page_id) fb_feed = fb_page.get_feed(fields=fields, params={"limit": limit}) fb_post_list = list(fb_feed) print("Retrieved {} posts".format(len(fb_post_list))) return fb_post_list, page_token
def page_insights(): id = '553748511770269' post = Page(id).get_insights(params=params) #for i in range(len(postid)): print(post) #dic_post=dict(post).json.dumps() '''for keys,item in post[1].items(): #converting to dictionary
def get_media_id_by_text(self, text): fields = ["caption"] params = {} media = Page(self.business_acc_id + '/media').api_get( fields=fields, params=params, ) for m in media["data"]: if text in m["caption"]: self.media_id = m["id"]
def _get_instagram_business_id(): fields = ["instagram_business_account"] params = {} accounts = Page('me/accounts').api_get( fields=fields, params=params, ) for acc in accounts["data"]: if "instagram_business_account" in acc: return acc["instagram_business_account"]["id"]
def test_runs_correctly(self): biz_id_1 = random.gen_string_id() biz_id_2 = random.gen_string_id() page_id_1 = random.gen_string_id() page_id_2 = random.gen_string_id() page_id_3 = random.gen_string_id() page_id_4 = random.gen_string_id() businesses = [Business(fbid=biz_id_1), Business(fbid=biz_id_2)] client_pages = [Page(fbid=page_id_1), Page(fbid=page_id_2)] owned_pages = [Page(fbid=page_id_3), Page(fbid=page_id_4)] job_scope = JobScope( ad_account_id='0', sweep_id=self.sweep_id, entity_type=Entity.Scope, entity_id=self.scope_id, report_type=ReportType.import_pages, report_variant=Entity.Page, tokens=['token'], ) with SweepRunningFlag(job_scope.sweep_id), mock.patch.object( FacebookRequest, 'execute', return_value=businesses) as gp, mock.patch.object( Business, 'get_client_pages', return_value=client_pages), mock.patch.object( Business, 'get_owned_pages', return_value=owned_pages), mock.patch.object( report_job_status_task, 'delay') as status_task: collect_pages_from_business_task(job_scope, JobContext()) assert gp.called assert status_task.called # it was called many times, but we care about the last time only pp, kk = status_task.call_args assert not kk assert pp == (JobStatus.Done, job_scope)
def get_comments(self, next_page=None, clist=[]): fields = ["text", "username"] params = { "limit": 50, "after": next_page, } comments = Page(str(self.media_id) + '/comments').api_get( fields=fields, params=params, ) if "paging" in comments: return clist + self.get_comments( next_page=comments["paging"]["cursors"]["after"], clist=comments["data"]) else: return clist + comments["data"]
# of this software is subject to the Facebook Developer Principles and # Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebook_business.adobjects.page import Page from facebook_business.adobjects.photo import Photo from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<ID>' FacebookAdsApi.init(access_token=access_token) fields = [] params = { 'url': 'https://www.facebook.com/images/fb_icon_325x325.png', 'published': 'false', } print Page(id).create_photo( fields=fields, params=params, )
# of this software is subject to the Facebook Developer Principles and # Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebook_business.adobjects.page import Page from facebook_business.adobjects.pagepost import PagePost from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<PAGE_ID>' FacebookAdsApi.init(access_token=access_token) fields = [ ] params = { 'message': 'This is a test value', } print Page(id).create_feed( fields=fields, params=params, )
# Facebook. # As with any software that integrates with the Facebook platform, your use # of this software is subject to the Facebook Developer Principles and # Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebook_business.adobjects.page import Page from facebook_business.adobjects.pagepost import PagePost from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<PAGE_ID>' FacebookAdsApi.init(access_token=access_token) fields = [] params = {} print Page(id).get_feed( fields=fields, params=params, )
def publish_ad(): #publish_ad.py is the definitive workflow for any questions regarding the publish_ad method try: # edge case to determine if page has leadgen_tos_accepted # reference leadgen_tos_accepted.py for questions page_id = request.form['page'] # '218711598949970' # abc realty FacebookAdsApi.init(access_token=g.user['access_token'], api_version='v3.3') # another option to get page_access_token is to call User(id).get_accounts as outlined here https://developers.facebook.com/docs/marketing-api/guides/lead-ads/retrieving#webhooks result = Page( page_id ).api_get( # api_get is the way to get a field from an object fields=['access_token'], params={}, ) page_access_token = result['access_token'] print("page_access_token - long?: " + str(page_access_token)) # add page_access_token to pages table for /webhook lead retrieval db.execute( "INSERT INTO pages (user_table_id, page_id, page_access_token) VALUES (:user_table_id, :page_id, :page_access_token)", user_table_id=session["id"], page_id=page_id, page_access_token=page_access_token) # get leadgen_tos_accepted from marketing api FacebookAdsApi.init(access_token=page_access_token, api_version='v3.3') leadad_tos_accepted = Page( page_id ).api_get( # api_get is the way to get a field from an object fields=['leadgen_tos_accepted'], params={}, ) if leadad_tos_accepted['leadgen_tos_accepted'] is False: return jsonify({'tos_accepted': False}) # initialize variables used during ad creation # ad_account = 'act_804097463107225' #hardcode to prevent publishing to bobs account # request.form['ad_account'] # set ad_account equal to user selected ad_account ad_account = request.form[ 'ad_account'] # set ad_account equal to user selected ad_account url = request.form['url'] privacy_policy = "https://fbapp0111.herokuapp.com/terms" # what if app users could all use the same privacy policy that I host on the app message = request.form['text'] headline = request.form['headline'] budget = request.form['budget'] image_url = request.form['image'] city = request.form['city_key'] print(ad_account) print(url) print(privacy_policy) print(message) print(headline) print(budget) print(image_url) print(city) # Step 1: create a campaign; # Here's a reference for campaign creation: https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group#Creating fields = [] params = { 'name': "Campaign Name Placeholder", 'objective': 'LEAD_GENERATION', 'status': "PAUSED", # need to switch to active 'buying_type': "AUCTION", } campaign = AdAccount(ad_account).create_campaign( fields=fields, params=params, ) #session['lead_ad']['campaign_id'] = campaign["id"] # save campaign id in session # Step 2: create an ad set # here's a reference: https://developers.facebook.com/docs/marketing-api/reference/ad-account/ad_sets/ # https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group/adsets/ fields = [] params = { 'name': "Ad Set Name Placeholder", 'optimization_goal': 'LEAD_GENERATION', 'billing_event': 'IMPRESSIONS', 'bid_strategy': 'LOWEST_COST_WITHOUT_CAP', 'lifetime_budget': budget, # $1 'end_time': datetime.now() + timedelta(days=3), 'campaign_id': campaign["id"], "targeting": { "age_max": 65, "age_min": 18, "exclusions": { "interests": [{ "id": "6003278963980", "name": "Loan officer" }], "work_positions": [{ "id": "1025100880851927", "name": "Real Estate Agent/Broker" }, { "id": "111867022164671", "name": "Real estate broker" }, { "id": "171815889531702", "name": "Real Estate Agent/Salesperson" }] }, "flexible_spec": [{ "interests": [{ "id": "1661352784116422", "name": "Realtor.com" }, { "id": "6002925289859", "name": "realtor.com" }, { "id": "6003174415534", "name": "First-time buyer" }, { "id": "6003307244821", "name": "Trulia" }, { "id": "6003496612657", "name": "Homes.com" }, { "id": "6003909817136", "name": "Zillow" }, { "id": "6003970928096", "name": "House Hunting" }, { "id": "6015042704805", "name": "trulia real estate" }] }], "geo_locations": { "location_types": ["home", "recent"], 'cities': [{ 'key': city, 'radius': 15, 'distance_unit': 'mile' }] }, "publisher_platforms": ["facebook"], "facebook_positions": ["feed"], "device_platforms": ["mobile"] }, 'status': 'ACTIVE', 'promoted_object': { 'page_id': page_id }, } ad_set = AdAccount(ad_account).create_ad_set( fields=fields, params=params, ) # Step 3: create a form; # here's a reference document: https://developers.facebook.com/docs/marketing-api/guides/lead-ads/create # for a list of pre-fill questions, expand the questions parameter here: https://developers.facebook.com/docs/graph-api/reference/page/leadgen_forms/#Creating fields = [] params = { # these fields can be found in under the page reference: https://developers.facebook.com/docs/graph-api/reference/page/ 'name': str(datetime.now() ), # name must be unique so just use current date and time 'follow_up_action_url': url, # 'question_page_custom_headline': "Form Question_Page_ Placeholder"'question page title', 'questions': [ { "key": "full_name", "type": "FULL_NAME", }, { "key": "email", "type": "EMAIL", }, { "key": "phone", "type": "PHONE", }, ], #'privacy_policy_url': "https://fbapp0111.herokuapp.com/terms", #'privacy_policy': 'Object', 'privacy_policy': { 'url': privacy_policy, 'link_text': 'Privacy.' }, # https://developers.facebook.com/docs/graph-api/reference/page/ #'legal_content_id': 'string', # thank_you_page is optional # "leadgen_tos_accepted": True } #FacebookAdsApi.init(access_token=session['page_access_token']) lead_gen_form = ( Page(page_id). create_lead_gen_form( # ABC realty page_id: 218711598949970 shaw marketing page_id: #1775351279446344 fields=fields, params=params, )) # Step 4: create a creative fields = [] params = { 'object_story_spec': { 'page_id': page_id, 'link_data': { 'message': message, 'link': 'http://fb.me/', 'picture': image_url, 'name': headline, #'caption':'WWW.ITUNES.COM', #'description':'The link description', #'title': adheadline, 'call_to_action': { 'type': 'LEARN_MORE', # other options, include: APPLY_NOW, DOWNLOAD, GET_QUOTE, LEARN_MORE, SIGN_UP, SUBSCRIBE 'value': { 'link': 'http://fb.me/', 'lead_gen_form_id': lead_gen_form['id'] } } } }, } #print(g.user['access_token']) #FacebookAdsApi.init(access_token=g.user['access_token']) # requires user access token creative = AdAccount( ad_account).create_ad_creative( # requires user access token fields=fields, params=params, ) # Step 5: create an ad, which requires the creative_id and adset_id fields = [] params = { 'name': 'Ad Name Placeholder', 'adset_id': ad_set["id"], 'creative': { 'creative_id': creative["id"] }, 'status': 'ACTIVE', } ad = AdAccount(ad_account).create_ad( fields=fields, params=params, ) error = "" # add new ad to db db.execute( "INSERT INTO ads (fb_user_id, campaign_id, lead_gen_form_id, creative_id, ad_account_id, page_id, users_table_id) VALUES (:fb_user_id, :campaign_id, :lead_gen_form_id, :creative_id, :ad_account_id, :page_id, :users_table_id)", fb_user_id=g.user['user_id'], campaign_id=campaign["id"], lead_gen_form_id=lead_gen_form['id'], creative_id=creative["id"], ad_account_id=ad_account, page_id=page_id, users_table_id=session["id"]) return jsonify( {'error': error}) # return facebook-specific error message if there is one except FacebookError as e: error = "Whoops! Error Publishing The Ad." if e.body(): error = e.body() print(error) error = error['error']['error_user_msg'] if error == "Please add a valid payment method to your ad account.": id = ad_account.replace("act_", "") #act_355306888659087 print(id) url = "https://www.facebook.com/ads/manager/account_settings/account_billing/?act=" + id + "&pid=p1&page=account_settings&tab=account_billing_settings" print(url) return jsonify({'error': error, 'url': url}) return jsonify( {'error': error}) # return facebook-specific error message if there is one
# Facebook. # As with any software that integrates with the Facebook platform, your use # of this software is subject to the Facebook Developer Principles and # Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebook_business.adobjects.page import Page from facebook_business.adobjects.pagepost import PagePost from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<PAGE_ID>' FacebookAdsApi.init(access_token=access_token) fields = [] params = {} print Page(id).get_posts( fields=fields, params=params, )
# Facebook. # As with any software that integrates with the Facebook platform, your use # of this software is subject to the Facebook Developer Principles and # Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebook_business.adobjects.page import Page from facebook_business.adobjects.user import User from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<PAGE_ID>' FacebookAdsApi.init(access_token=access_token) fields = [] params = {} print Page(id).get_roles( fields=fields, params=params, )
# As with any software that integrates with the Facebook platform, your use # of this software is subject to the Facebook Developer Principles and # Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebook_business.adobjects.page import Page from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<PAGE_ID>' FacebookAdsApi.init(access_token=access_token) fields = [] params = { 'subscribed_fields': 'leadgen', } print Page(id).create_subscribed_app( fields=fields, params=params, )
# As with any software that integrates with the Facebook platform, your use # of this software is subject to the Facebook Developer Principles and # Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebook_business.adobjects.page import Page from facebook_business.adobjects.profilepicturesource import ProfilePictureSource from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<ID>' FacebookAdsApi.init(access_token=access_token) fields = [] params = { 'redirect': '0', } print Page(id).get_picture( fields=fields, params=params, )
# of this software is subject to the Facebook Developer Principles and # Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebook_business.adobjects.page import Page from facebook_business.adobjects.pageadminnote import PageAdminNote from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<ID>' FacebookAdsApi.init(access_token=access_token) fields = [] params = { 'body': 'text', 'user_id': '<customerID>', } print Page(id).create_admin_note( fields=fields, params=params, )
fields=fields, params=params, ) print 'pages', pages page_id = pages[0].get_id() print 'page_id:', page_id, '\n' # Switch access token to page access token FacebookAdsApi.init(access_token=pages[0].access_token) # Page feed create fields = [] params = { 'message': 'This is a test value', } pagepost = Page(page_id).create_feed( fields=fields, params=params, ) print 'pagepost', pagepost pagepost_id = pagepost.get_id() print 'pagepost_id:', pagepost_id, '\n' # Switch access token back to user access token FacebookAdsApi.init(access_token=access_token) # User adaccounts get fields = [] params = {} adaccounts = User(user_id).get_ad_accounts( fields=fields, params=params, ) print 'adaccounts', adaccounts
# Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebook_business.adobjects.page import Page from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<ID>' FacebookAdsApi.init(access_token=access_token) fields = [ ] params = { 'type': 'adradiussuggestion', 'latitude': '51.5152253', 'longitude': '-0.1423029', } print Page(id).get( fields=fields, params=params, )
# Facebook. # As with any software that integrates with the Facebook platform, your use # of this software is subject to the Facebook Developer Principles and # Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebook_business.adobjects.page import Page from facebook_business.adobjects.photo import Photo from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<ID>' FacebookAdsApi.init(access_token=access_token) fields = [] params = {} print Page(id).get_photos( fields=fields, params=params, )
# shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebook_business.adobjects.page import Page from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<ID>' FacebookAdsApi.init(access_token=access_token) fields = [ 'location{latitude', 'longitude}', 'is_permanently_closed', ] params = { 'limit': '30000', } print Page(id).get_locations( fields=fields, params=params, )
def _get_instagram_user(self, page: Page) -> IGUser: return IGUser(page.get("instagram_business_account").get("id"))
# As with any software that integrates with the Facebook platform, your use # of this software is subject to the Facebook Developer Principles and # Policies [http://developers.facebook.com/policy/]. This copyright notice # shall be included in all copies or substantial portions of the software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebook_business.adobjects.page import Page from facebook_business.adobjects.pagelabel import PageLabel from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<ID>' FacebookAdsApi.init(access_token=access_token) fields = [] params = { 'name': 'This is a test value', } print Page(id).create_label( fields=fields, params=params, )