config = json.load(config_file) config_file.close() account_id = config['account_id'] access_token = config['access_token'] app_id = config['app_id'] app_secret = config['app_secret'] FacebookAdsApi.init(app_id, app_secret, access_token) # _DOC open [ADACCOUNT_READ] from facebookads.objects import AdAccount account = AdAccount(account_id) account.remote_read(fields=[AdAccount.Field.name, AdAccount.Field.balance]) print(account[AdAccount.Field.name]) print(account[AdAccount.Field.balance]) # _DOC close [ADACCOUNT_READ] from facebookads.objects import AdAccount account = AdAccount(account_id) account.remote_read(fields=[AdAccount.Field.name]) old_name = account[AdAccount.Field.name] # _DOC open [ADACCOUNT_UPDATE] from facebookads.objects import AdAccount account = AdAccount(account_id)
account_id = config['account_id'] access_token = config['access_token'] app_id = config['app_id'] app_secret = config['app_secret'] FacebookAdsApi.init(app_id, app_secret, access_token) # _DOC open [ADACCOUNT_READ] # _DOC vars [account_id:s] from facebookads.objects import AdAccount account = AdAccount(account_id) account.remote_read(fields=[ AdAccount.Field.name, AdAccount.Field.balance ]) print(account[AdAccount.Field.name]) print(account[AdAccount.Field.balance]) # _DOC close [ADACCOUNT_READ] # _DOC vars [account_id:s] from facebookads.objects import AdAccount account = AdAccount(account_id) account.remote_read(fields=[AdAccount.Field.name]) old_name = account[AdAccount.Field.name] # _DOC open [ADACCOUNT_UPDATE] # _DOC vars [account_id:s] from facebookads.objects import AdAccount
from __future__ import print_function from __future__ import unicode_literals ''' This is a template for DocSmith samples in Python. This file will throw an exception. This is used to test facebookads/docs_runner/doc_runner.py when something breaks ''' import sys import os this_dir = os.path.dirname(__file__) repo_dir = os.path.join(this_dir, os.pardir, os.pardir) sys.path.insert(1, repo_dir) from facebookads import bootstrap bootstrap.auth() ''' Example tha intentionally throws an exception to be used as a test for DocExampleTest ''' from facebookads.objects import AdAccount if __name__ == '__main__': ad_account_id = 'invalid_id_1111' print('**** READ AD ACCOUNT ****') ad_account = AdAccount(fbid=ad_account_id) ad_account.remote_read() print(ad_account.remote_read())
from __future__ import unicode_literals ''' This is a template for DocSmith samples in Python. This file will throw an exception. This is used to test facebookads/docs_runner/doc_runner.py when something breaks ''' import sys import os this_dir = os.path.dirname(__file__) repo_dir = os.path.join(this_dir, os.pardir, os.pardir) sys.path.insert(1, repo_dir) from facebookads import bootstrap bootstrap.auth() ''' Example tha intentionally throws an exception to be used as a test for DocExampleTest ''' from facebookads.objects import AdAccount if __name__ == '__main__': ad_account_id = 'invalid_id_1111' print('**** READ AD ACCOUNT ****') ad_account = AdAccount(fbid=ad_account_id) ad_account.remote_read() print(ad_account.remote_read())
# DEALINGS IN THE SOFTWARE. from facebookads import test_config from facebookads.objects import AdLabel from examples.docs import fixtures ad_account_id = test_config.account_id # _DOC open [ADACCOUNT_READ] # _DOC vars [ad_account_id:s] from facebookads.objects import AdAccount account = AdAccount(ad_account_id) account.remote_read(fields=[ AdAccount.Field.name, AdAccount.Field.balance ]) print(account[AdAccount.Field.name]) print(account[AdAccount.Field.balance]) # _DOC close [ADACCOUNT_READ] # _DOC open [ADACCOUNT_READ_TOS_ACCEPTED] # _DOC vars [ad_account_id:s] from facebookads.objects import AdAccount account = AdAccount(ad_account_id) account.remote_read(fields=[AdAccount.Field.tos_accepted]) for tos in account[AdAccount.Field.tos_accepted]: print(tos)
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. from facebookads import test_config from facebookads.objects import AdLabel from examples.docs import fixtures ad_account_id = test_config.account_id # _DOC open [ADACCOUNT_READ] # _DOC vars [ad_account_id:s] from facebookads.objects import AdAccount account = AdAccount(ad_account_id) account.remote_read(fields=[AdAccount.Field.name, AdAccount.Field.balance]) print(account[AdAccount.Field.name]) print(account[AdAccount.Field.balance]) # _DOC close [ADACCOUNT_READ] # _DOC open [ADACCOUNT_READ_TOS_ACCEPTED] # _DOC vars [ad_account_id:s] from facebookads.objects import AdAccount account = AdAccount(ad_account_id) account.remote_read(fields=[AdAccount.Field.tos_accepted]) for tos in account[AdAccount.Field.tos_accepted]: print(tos) # _DOC close [ADACCOUNT_READ_TOS_ACCEPTED]
# 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 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 facebookads import test_config ad_account_id = test_config.account_id # _DOC open [ADACCOUNT_READ_TOS_ACCEPTED] # _DOC vars [ad_account_id:s] from facebookads.objects import AdAccount account = AdAccount(ad_account_id) account.remote_read(fields=[AdAccount.Field.tos_accepted]) for tos in account[AdAccount.Field.tos_accepted]: print(tos) # _DOC close [ADACCOUNT_READ_TOS_ACCEPTED]
# 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 facebookads import test_config from facebookads.objects import AdAccount ad_account_id = test_config.account_id account = AdAccount(ad_account_id) account.remote_read(fields=[AdAccount.Field.name]) old_name = account[AdAccount.Field.name] # _DOC open [ADACCOUNT_UPDATE] # _DOC vars [ad_account_id:s] from facebookads.objects import AdAccount account = AdAccount(ad_account_id) account[AdAccount.Field.name] = 'New Name' account.remote_update() # _DOC close [ADACCOUNT_UPDATE] account[AdAccount.Field.name] = old_name account.remote_update()
# 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. ''' This is a template for DocSmith samples in Python. Copy it and create yours Code should follow guidelines at https://our.intern.facebook.com/intern/wiki/Solutions_Engineering/DocSmith facebookads repo folder must be added to PYTHONPATH in order to run Comments on style: - IDs should be defined outside of _DOC blocks so they don't appear into the docs ''' from facebookads import test_config as config ad_account_id = config.account_id #! _DOC open [READ_ADACCOUNT] # _DOC vars [ad_account_id] from facebookads.objects import AdAccount ad_account = AdAccount(fbid=ad_account_id) ad_account.remote_read() print(ad_account) #! _DOC close [READ_ADACCOUNT]
# 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. ''' This is a template for DocSmith samples in Python. Copy it and create yours Code should follow guidelines at https://our.intern.facebook.com/intern/wiki/Solutions_Engineering/DocSmith facebookads repo folder must be added to PYTHONPATH in order to run Comments on style: - IDs should be defined outside of _DOC blocks so they don't appear into the docs ''' from facebookads import test_config as config ad_account_id = config.account_id #! _DOC open [READ_ADACCOUNT] # _DOC vars [ad_account_id] from facebookads.objects import AdAccount ad_account = AdAccount(fbid=ad_account_id) ad_account.remote_read() print(ad_account) #! _DOC close [READ_ADACCOUNT]