当前位置: 首页>>代码示例>>Python>>正文


Python FacebookAdsApi.get_default_api方法代码示例

本文整理汇总了Python中facebookads.api.FacebookAdsApi.get_default_api方法的典型用法代码示例。如果您正苦于以下问题:Python FacebookAdsApi.get_default_api方法的具体用法?Python FacebookAdsApi.get_default_api怎么用?Python FacebookAdsApi.get_default_api使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在facebookads.api.FacebookAdsApi的用法示例。


在下文中一共展示了FacebookAdsApi.get_default_api方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from facebookads.api import FacebookAdsApi [as 别名]
# 或者: from facebookads.api.FacebookAdsApi import get_default_api [as 别名]
		def __init__(self, my_access_token, my_account_id, my_app_id = 'XXXXXXX', my_app_secret='XXXXXXXXXX'):
				self.my_app_id = my_app_id
				self.my_app_secret = my_app_secret
				self.my_access_token = my_access_token
				self.my_account_id = my_account_id
				FacebookAdsApi.init(self.my_app_id, self.my_app_secret, self.my_access_token)
				self.api = FacebookAdsApi.get_default_api()
开发者ID:prarthanabhattarai,项目名称:AdReportProject,代码行数:9,代码来源:getdata.py

示例2: get_by_ids

# 需要导入模块: from facebookads.api import FacebookAdsApi [as 别名]
# 或者: from facebookads.api.FacebookAdsApi import get_default_api [as 别名]
 def get_by_ids(cls, ids, params=None, fields=None, api=None):
     api = api or FacebookAdsApi.get_default_api()
     params = dict(params or {})
     cls._assign_fields_to_params(fields, params)
     params["ids"] = ",".join(map(str, ids))
     response = api.call("GET", ["/"], params=params)
     result = []
     for fbid, data in response.json().items():
         obj = cls(fbid, api=api)
         obj._set_data(data)
         result.append(obj)
     return result
开发者ID:yanbf,项目名称:facebook-python-ads-sdk,代码行数:14,代码来源:abstractcrudobject.py

示例3: __init__

# 需要导入模块: from facebookads.api import FacebookAdsApi [as 别名]
# 或者: from facebookads.api.FacebookAdsApi import get_default_api [as 别名]
    def __init__(self, fbid=None, parent_id=None, api=None):
        """Initializes a CRUD object.
        Args:
            fbid (optional): The id of the object ont the Graph.
            parent_id (optional): The id of the object's parent.
            api (optional): An api object which all calls will go through. If
                an api object is not specified, api calls will revert to going
                through the default api.
        """
        super(AbstractCrudObject, self).__init__()

        self._api = api or FacebookAdsApi.get_default_api()
        self._changes = {}
        self._parent_id = parent_id
        self._data['id'] = fbid
        self._include_summary = True
开发者ID:abendleiter,项目名称:facebook-python-ads-sdk,代码行数:18,代码来源:abstractcrudobject.py

示例4: __init__

# 需要导入模块: from facebookads.api import FacebookAdsApi [as 别名]
# 或者: from facebookads.api.FacebookAdsApi import get_default_api [as 别名]
    def __init__(self, fbid=None, parent_id=None, api=None):
        """Initializes a CRUD object.
        Args:
            fbid (optional): The id of the object ont the Graph.
            parent_id (optional): The id of the object's parent.
            api (optional): An api object which all calls will go through. If
                an api object is not specified, api calls will revert to going
                through the default api.
        """
        super(AbstractCrudObject, self).__init__()

        self._api = api or FacebookAdsApi.get_default_api()
        self._changes = {}
        if (parent_id is not None):
            warning_message = "parent_id as a parameter of constructor is " \
                  "being deprecated."
            logging.warning(warning_message)
        self._parent_id = parent_id
        self._data['id'] = fbid
        self._include_summary = True
开发者ID:derskeal,项目名称:facebook-python-ads-sdk,代码行数:22,代码来源:abstractcrudobject.py

示例5: remote_create_from_zip

# 需要导入模块: from facebookads.api import FacebookAdsApi [as 别名]
# 或者: from facebookads.api.FacebookAdsApi import get_default_api [as 别名]
    def remote_create_from_zip(cls, filename, parent_id, api=None):
        api = api or FacebookAdsApi.get_default_api()
        open_file = open(filename, 'rb')
        response = api.call(
            'POST',
            (parent_id, cls.get_endpoint()),
            files={filename: open_file},
        )
        open_file.close()

        data = response.json()

        objs = []
        for image_filename in data['images']:
            image = cls(parent_id=parent_id)
            image.update(data['images'][image_filename])
            image[cls.Field.id] = '%s:%s' % (
                parent_id[4:],
                data['images'][image_filename][cls.Field.hash],
            )
            objs.append(image)

        return objs
开发者ID:Jovani,项目名称:facebook-python-ads-sdk,代码行数:25,代码来源:adimagemixin.py

示例6: search

# 需要导入模块: from facebookads.api import FacebookAdsApi [as 别名]
# 或者: from facebookads.api.FacebookAdsApi import get_default_api [as 别名]
    def search(cls, params=None, api=None):
        api = api or FacebookAdsApi.get_default_api()
        if not api:
            raise FacebookBadObjectError(
                "An Api instance must be provided as an argument or set as "
                "the default Api in FacebookAdsApi.",
            )

        params = {} if not params else params.copy()
        response = api.call(
            FacebookAdsApi.HTTP_METHOD_GET,
            "/".join((
                FacebookSession.GRAPH,
                FacebookAdsApi.API_VERSION,
                'search'
            )),
            params,
        ).json()

        ret_val = []
        if response:
            keys = response['data']
            # The response object can be either a dictionary of dictionaries
            # or a dictionary of lists.
            if isinstance(keys, list):
                for item in keys:
                    search_obj = TargetingSearch()
                    search_obj.update(item)
                    ret_val.append(search_obj)
            elif isinstance(keys, dict):
                for item in keys:
                    search_obj = TargetingSearch()
                    search_obj.update(keys[item])
                    if keys[item]:
                        ret_val.append(search_obj)
        return ret_val
开发者ID:IFTS,项目名称:facebook-python-ads-sdk,代码行数:38,代码来源:targetingsearch.py

示例7: print

# 需要导入模块: from facebookads.api import FacebookAdsApi [as 别名]
# 或者: from facebookads.api.FacebookAdsApi import get_default_api [as 别名]
# 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

page_id = test_config.page_id

# _DOC oncall [pruno]
# _DOC open [PAGE_GET_LOCATIONS]
# _DOC vars [page_id]
from facebookads.api import FacebookAdsApi

response = FacebookAdsApi.get_default_api().call(
    'GET',
    ('/{}/locations'.format(page_id),),
    {
        'fields': 'location',
    }).json()

for location in response['data']:
    print("{},{}\n".format(
        location['location']['latitude'],
        location['location']['longitude'],
    ))
# _DOC close [PAGE_GET_LOCATIONS]
开发者ID:dud3,项目名称:facebook-python-ads-sdk,代码行数:32,代码来源:PAGE_GET_LOCATIONS.py

示例8: len

# 需要导入模块: from facebookads.api import FacebookAdsApi [as 别名]
# 或者: from facebookads.api.FacebookAdsApi import get_default_api [as 别名]
# 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

page_id = test_config.page_id

# _DOC oncall [pruno]
# _DOC open [PAGE_CHECK_LOCATIONS]
# _DOC vars [page_id]
from facebookads.api import FacebookAdsApi

response = FacebookAdsApi.get_default_api().call(
    'GET',
    ('/{}/locations'.format(page_id),),
    {
        'limit': 1,
    }).json()

has_locations = len(response['data']) > 0
# _DOC close [PAGE_CHECK_LOCATIONS]
开发者ID:dud3,项目名称:facebook-python-ads-sdk,代码行数:32,代码来源:PAGE_CHECK_LOCATIONS.py


注:本文中的facebookads.api.FacebookAdsApi.get_default_api方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。