Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
59b514b
Update readme: changed `AdUser` class to `User` (#653)
Sep 13, 2023
8ee7d0c
Update LICENSE and Header
stcheng Sep 13, 2023
18cc826
docs: Fix a few typos (#596)
timgates42 Sep 14, 2023
fb26887
Auto-generated python SDK code update
Sep 14, 2023
df8fc8e
Auto-generated python SDK code update
Sep 26, 2023
22d7355
Address Python Single Quote Escape Issue
stcheng Oct 2, 2023
438b9b0
feat: Us e `with` when opening file to ensure closure ✨ (#604)
yezz123 Oct 3, 2023
7511fe3
Chore: F ix Minor Issue ✨ (#601)
yezz123 Oct 4, 2023
a85a1bd
chore: Remove unnecessary `else` after guard condition (#602)
yezz123 Oct 4, 2023
7d087b3
Chore: Use `x` is None rather than `x == None` (#600)
yezz123 Oct 4, 2023
9b0bf1d
Auto-generated python SDK code update
stcheng Oct 15, 2023
be38bc6
Auto-generated python SDK code update
Nov 2, 2023
c7b025a
Auto-generated python SDK code update
Dec 4, 2023
9e94f20
Updated typechecker.py to handle <list<map<string, string>>> correctl…
joshuamc98 Jan 23, 2024
c0d3508
Fix missing AppData field in Event object
Jan 23, 2024
21557b2
Fix Python Paging Infinite Issue
stcheng Jan 23, 2024
03f1096
Support KeyValue Type for Ruby PHP and Python
stcheng Jan 23, 2024
1e423d2
Update requirements.txt (#660)
anukaal Jan 23, 2024
10c9eb6
Auto-generated python SDK code update
Jan 23, 2024
98cc9bb
Remove enum34 Requirement
stcheng Feb 1, 2024
e43a205
Auto-generated python SDK code update
Mar 6, 2024
2c7166d
Adding support to WhatsApp events on Business SDK
Mar 7, 2024
bec04ac
Set object parser on Cursor when executing a request (#636)
guschnwg Mar 7, 2024
3d68190
Update Supported Destination Types
stcheng Mar 7, 2024
0cff587
Parse nested objects (#666)
aluminiumgeek Mar 13, 2024
03898e9
Override Enum EnumAffectedChannels for All Languages
stcheng Mar 15, 2024
ff8c1c6
Auto-generated python SDK code update
Mar 19, 2024
063d440
Auto-generated python SDK code update
Apr 15, 2024
0a8f347
Auto-generated python SDK code update
Jun 14, 2024
22a059c
Merge tag '20.0.0' into 20.0.0+work4
jolancornevin Jul 29, 2024
92874e2
use 3.10 in cci
jolancornevin Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 13 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@
version: 2

shared: &shared
steps:
- checkout
# Define config in CircleCi's project settings → Environment Variables
- run: echo \{\"app_id\":\"$FB_APP_ID\",\"app_secret\":\"$FB_APP_SECRET\",\"act_id\":\"act_$FB_ACCOUNT_ID\",\"page_id\":\"$FB_PAGE_ID\",\"access_token\":\"$FB_ACCESS_TOKEN\",\"business\":\"$FB_BUSINESS_ID\",\"sec_business\":\"$FB_BUSINESS_ID_BIS\",\"sec_act_id\":\"act_$FB_ACCOUNT_ID_BIS\"\} > config.json
# Cheapo virtualenv, CCi images use the circleci user so no writing to the root site-packages
- run: virtualenv venv
- run: venv/bin/python setup.py install
- run: venv/bin/python -m facebook_business.test.unit
steps:
- checkout
# Define config in CircleCi's project settings → Environment Variables
- run: echo \{\"app_id\":\"$FB_APP_ID\",\"app_secret\":\"$FB_APP_SECRET\",\"act_id\":\"act_$FB_ACCOUNT_ID\",\"page_id\":\"$FB_PAGE_ID\",\"access_token\":\"$FB_ACCESS_TOKEN\",\"business\":\"$FB_BUSINESS_ID\",\"sec_business\":\"$FB_BUSINESS_ID_BIS\",\"sec_act_id\":\"act_$FB_ACCOUNT_ID_BIS\"\} > config.json
# Cheapo virtualenv, CCi images use the circleci user so no writing to the root site-packages
- run: pip install --no-cache-dir virtualenv && virtualenv venv3
- run: virtualenv venv
- run: venv/bin/python setup.py install
- run: venv/bin/python -m facebook_business.test.unit

jobs:
python-3.7: # Not specified in tox.ini
python-3.10: # Not specified in tox.ini
<<: *shared
docker:
- image: circleci/python:3.7-stretch-node


- image: python:3.7-buster

all_jobs: &all_jobs
jobs:
- python-3.7
jobs:
- python-3.10

workflows:
version: 2
Expand Down
18 changes: 18 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright (c) Meta Platforms, Inc. and affiliates.
All rights reserved.

You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
copy, modify, and distribute this software in source code or binary form for use
in connection with the web services and APIs provided by Facebook.

As with any software that integrates with the Facebook platform, your use of
this software is subject to the Facebook Platform Policy
[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.
19 changes: 0 additions & 19 deletions LICENSE.txt

This file was deleted.

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ API using a specific api object instead of the default, you can specify the
### Edges

Look at the methods of an object to see what associations over which we can
iterate. For example an ``AdUser`` object has a method ``get_ad_accounts`` which
iterate. For example an ``User`` object has a method ``get_ad_accounts`` which
returns an iterator of ``AdAccount`` objects.

### Ad Account
Expand All @@ -183,7 +183,8 @@ Let's get all the ad accounts for the user with the given access token. I only
have one account so the following is printed:

```python
>>> me = adobjects.AdUser(fbid='me')
>>> from facebook_business.adobjects.user import User
>>> me = adobjects.User(fbid='me')
>>> my_accounts = list(me.get_ad_accounts())
>>> print(my_accounts)
[{ 'account_id': u'17842443', 'id': u'act_17842443'}]
Expand All @@ -192,7 +193,7 @@ have one account so the following is printed:
```

**WARNING**: We do not specify a keyword argument ``api=api`` when instantiating
the ``AdUser`` object here because we've already set the default api when
the ``User`` object here because we've already set the default api when
bootstrapping.

**NOTE**: We wrap the return value of ``get_ad_accounts`` with ``list()``
Expand Down
4 changes: 2 additions & 2 deletions examples/AdAccountAdSetsPostAdSetCreateCpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
'name': 'A CPA Ad Set',
'campaign_id': '<adCampaignLinkClicksID>',
'daily_budget': '5000',
'start_time': '2023-04-24T09:25:05-0700',
'end_time': '2023-05-01T09:25:05-0700',
'start_time': '2024-06-18T16:39:15-0700',
'end_time': '2024-06-25T16:39:15-0700',
'billing_event': 'IMPRESSIONS',
'optimization_goal': 'REACH',
'bid_amount': '1000',
Expand Down
4 changes: 2 additions & 2 deletions examples/AdAccountAdSetsPostAdSetCreateCpaAppEvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
'name': 'A CPA Ad Set optimized for App Events',
'campaign_id': '<adCampaignAppInstallsID>',
'daily_budget': '300',
'start_time': '2023-04-24T09:25:55-0700',
'end_time': '2023-05-01T09:25:55-0700',
'start_time': '2024-06-18T16:40:02-0700',
'end_time': '2024-06-25T16:40:02-0700',
'billing_event': 'IMPRESSIONS',
'optimization_goal': 'OFFSITE_CONVERSIONS',
'bid_amount': '100',
Expand Down
4 changes: 2 additions & 2 deletions examples/AdAccountAdSetsPostCreateAdSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
params = {
'name': 'My First AdSet',
'lifetime_budget': '20000',
'start_time': '2023-04-24T09:24:18-0700',
'end_time': '2023-05-01T09:24:18-0700',
'start_time': '2024-06-18T16:38:30-0700',
'end_time': '2024-06-25T16:38:30-0700',
'campaign_id': '<adCampaignLinkClicksID>',
'bid_amount': '500',
'billing_event': 'IMPRESSIONS',
Expand Down
4 changes: 2 additions & 2 deletions examples/AdAccountAdSetsPostDailyBudget20.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
params = {
'name': 'My First Adset',
'daily_budget': '2000',
'start_time': '2023-04-17T09:25:24-0700',
'end_time': '2023-04-24T09:25:24-0700',
'start_time': '2024-06-11T16:39:34-0700',
'end_time': '2024-06-18T16:39:34-0700',
'campaign_id': '<adCampaignLinkClicksID>',
'bid_amount': '100',
'billing_event': 'LINK_CLICKS',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
params = {
'name': 'My First Adset',
'lifetime_budget': '20000',
'start_time': '2023-04-17T09:25:36-0700',
'end_time': '2023-04-27T09:25:36-0700',
'start_time': '2024-06-11T16:39:43-0700',
'end_time': '2024-06-21T16:39:43-0700',
'campaign_id': '<adCampaignLinkClicksID>',
'bid_amount': '100',
'billing_event': 'LINK_CLICKS',
Expand Down
4 changes: 2 additions & 2 deletions examples/AdAccountAdSetsPostOptimizePostEngagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
params = {
'name': 'My First Adset',
'lifetime_budget': '20000',
'start_time': '2023-04-17T09:25:45-0700',
'end_time': '2023-04-27T09:25:45-0700',
'start_time': '2024-06-11T16:39:52-0700',
'end_time': '2024-06-21T16:39:52-0700',
'campaign_id': '<adCampaignLinkClicksID>',
'bid_amount': '500',
'billing_event': 'IMPRESSIONS',
Expand Down
2 changes: 1 addition & 1 deletion examples/AdgroupLeadsEdgeAdgroupLeadsFiltered.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
fields = [
]
params = {
'filtering': [{'field':'time_created','operator':'GREATER_THAN','value':1681144509}],
'filtering': [{'field':'time_created','operator':'GREATER_THAN','value':1717544918}],
}
print Ad(id).get_leads(
fields=fields,
Expand Down
2 changes: 1 addition & 1 deletion examples/AdsPixelEventsPost.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
fields = [
]
params = {
'data': [{'event_name':'PageView','event_time':1681748568,'user_data':{'fbc':'fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890','fbp':'fb.1.1558571054389.1098115397','em':'309a0a5c3e211326ae75ca18196d301a9bdbd1a882a4d2569511033da23f0abd'}}],
'data': [{'event_name':'PageView','event_time':1718149023,'user_data':{'fbc':'fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890','fbp':'fb.1.1558571054389.1098115397','em':'309a0a5c3e211326ae75ca18196d301a9bdbd1a882a4d2569511033da23f0abd'}}],
}
print AdsPixel(id).create_event(
fields=fields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
fields = [
]
params = {
'hotel_catalog_settings': {'pull_config_id':'<pullConfigID>'},
}
print ProductCatalog(id).update(
fields=fields,
Expand Down
5 changes: 2 additions & 3 deletions examples/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@

this_dir = os.path.dirname(__file__)
config_filename = os.path.join(this_dir, 'config.json')
config_file = open(config_filename)
config = json.load(config_file)
config_file.close()
with open(config_filename) as config_file:
config = json.load(config_file)

api = FacebookAdsApi.init(access_token=config['access_token'])
account_id = config['act_id']
Expand Down
6 changes: 3 additions & 3 deletions examples/batch_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Creates several ads using batch calls.
"""


from facebook_business import FacebookSession
from facebook_business import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount
Expand All @@ -35,9 +36,8 @@
this_dir = os.path.dirname(__file__)
config_filename = os.path.join(this_dir, 'config.json')

config_file = open(config_filename)
config = json.load(config_file)
config_file.close()
with open(config_filename) as config_file:
config = json.load(config_file)

### Setup session and api objects
session = FacebookSession(
Expand Down
6 changes: 3 additions & 3 deletions examples/batch_pause.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Pauses all active ad campaigns using batch calls.
"""


from facebook_business import FacebookSession
from facebook_business import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount
Expand All @@ -35,9 +36,8 @@
this_dir = os.path.dirname(__file__)
config_filename = os.path.join(this_dir, 'config.json')

config_file = open(config_filename)
config = json.load(config_file)
config_file.close()
with open(config_filename) as config_file:
config = json.load(config_file)

### Setup session and api objects
session = FacebookSession(
Expand Down
7 changes: 3 additions & 4 deletions examples/custom_audience_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
https://github.com/facebook/facebook-python-ads-sdk
"""


from facebook_business import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.customaudience import CustomAudience
Expand All @@ -38,10 +39,8 @@
this_dir = os.path.dirname(__file__)
config_filename = os.path.join(this_dir, 'config.json')

### Setup session and api objects
config_file = open(config_filename)
config = json.load(config_file)
config_file.close()
with open(config_filename) as config_file:
config = json.load(config_file)

auth_info = (
config['app_id'],
Expand Down
5 changes: 2 additions & 3 deletions examples/dpa-update/dpa_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
import sys
sys.path.insert(1, os.path.join(this_dir, os.pardir, os.pardir))

config_file = open(config_filename)
config = json.load(config_file)
config_file.close()
with open(config_filename) as config_file:
config = json.load(config_file)

from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.productcatalog import ProductCatalog
Expand Down
5 changes: 2 additions & 3 deletions examples/dpa-update/dpa_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
import sys
sys.path.insert(1, os.path.join(this_dir, os.pardir, os.pardir))

config_file = open(config_filename)
config = json.load(config_file)
config_file.close()
with open(config_filename) as config_file:
config = json.load(config_file)

from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.productcatalog import ProductCatalog
Expand Down
6 changes: 3 additions & 3 deletions examples/read_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Prints account permissions and campaign statistics.
"""


from facebook_business import FacebookSession
from facebook_business import FacebookAdsApi
from facebook_business.adobjects.campaign import Campaign as AdCampaign
Expand All @@ -35,9 +36,8 @@
this_dir = os.path.dirname(__file__)
config_filename = os.path.join(this_dir, 'config.json')

config_file = open(config_filename)
config = json.load(config_file)
config_file.close()
with open(config_filename) as config_file:
config = json.load(config_file)

### Setup session and api objects
session = FacebookSession(
Expand Down
17 changes: 8 additions & 9 deletions examples/simple_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Creates an ad through a utility function.
"""


from facebook_business import FacebookSession
from facebook_business import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount
Expand All @@ -36,9 +37,8 @@
this_dir = os.path.dirname(__file__)
config_filename = os.path.join(this_dir, 'config.json')

config_file = open(config_filename)
config = json.load(config_file)
config_file.close()
with open(config_filename) as config_file:
config = json.load(config_file)

### Setup session and api objects
session = FacebookSession(
Expand Down Expand Up @@ -88,10 +88,9 @@
'ad_format': AdPreview.AdFormat.right_column_standard
})
preview_filename = os.path.join(this_dir, 'preview_ad.html')
preview_file = open(preview_filename, 'w')
preview_file.write(
"<html><head><title>Facebook Ad Preview</title><body>%s</body></html>"
% preview.get_html()
)
preview_file.close()
with open(preview_filename, 'w') as preview_file:
preview_file.write(
"<html><head><title>Facebook Ad Preview</title><body>%s</body></html>"
% preview.get_html()
)
print('**** %s has been created!' % preview_filename)
6 changes: 3 additions & 3 deletions examples/upload_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Upload a video to adaccount
"""


import sys
import os

Expand All @@ -34,9 +35,8 @@

config_filename = os.path.join(sdk_path, './config.json')

config_file = open(config_filename)
config = json.load(config_file)
config_file.close()
with open(config_filename) as config_file:
config = json.load(config_file)

### Setup session and api objects
session = FacebookSession(
Expand Down
Loading