예제 #1
0
def create_video():
    video = AdVideo(parent_id=test_config.account_id)
    video[AdVideo.Field.filepath] = test_config.video_path
    video.remote_create()
    video.waitUntilEncodingReady()

    atexit.register(remote_delete, video)

    return video
예제 #2
0
def create_video():
    video = AdVideo(parent_id=test_config.account_id)
    video[AdVideo.Field.filepath] = test_config.video_path
    video.remote_create()
    video.waitUntilEncodingReady()

    atexit.register(remote_delete, video)

    return video
import os
import configparser
config = configparser.RawConfigParser()
this_dir = os.path.dirname(__file__)
config_filename = os.path.join(this_dir, 'my_app_session.cfg')

with open(config_filename) as config_file:
    config.readfp(config_file)

FacebookAdsApi.init(
    config.get('Authentication', 'app_id'),
    config.get('Authentication', 'app_secret'),
    config.get('Authentication', 'access_token'),
)

if __name__ == '__main__':
    my_account = AdAccount(config.get('Defaults', 'ad_account'))

    # create video object
    video = AdVideo(parent_id=my_account.get_id_assured())

    # set video fields
    video[AdVideo.Field.filepath] = os.path.join(this_dir, 'test_video.mp4')

    # remove create
    video.remote_create()
    video.waitUntilEncodingReady()

    print(video)
# Copyright 2014 Facebook, Inc.

# 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 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 examples.docs import fixtures
video_id = fixtures.create_video().get_id()

# _DOC open [ADVIDEO_GET_THUMBNAILS]
# _DOC vars [video_id]
from facebookads.objects import AdVideo

video = AdVideo(video_id)
thumbnails = video.get_thumbnails()
# _DOC close [ADVIDEO_GET_THUMBNAILS]
# 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

video_path = test_config.video_path
ad_account_id = test_config.account_id

# _DOC open [ADVIDEO_CREATE]
# _DOC vars [ad_account_id:s, video_path:s]
from facebookads.objects import AdVideo

video = AdVideo(parent_id=ad_account_id)
video[AdVideo.Field.filepath] = video_path
video.remote_create()
# _DOC close [ADVIDEO_CREATE]

video.remote_delete()
import configparser
import os

config = configparser.RawConfigParser()
this_dir = os.path.dirname(__file__)
config_filename = os.path.join(this_dir, 'my_app_session.cfg')

with open(config_filename) as config_file:
    config.readfp(config_file)

FacebookAdsApi.init(
    config.get('Authentication', 'app_id'),
    config.get('Authentication', 'app_secret'),
    config.get('Authentication', 'access_token'),
)

if __name__ == '__main__':
    my_account = AdAccount('act_<AD_ACCOUNT_ID>')

    # create video object
    video = AdVideo(parent_id=my_account.get_id_assured())

    # set video fields
    video[AdVideo.Field.filepath] = os.path.join(this_dir, 'test_video.mp4')

    # remove create
    video.remote_create()
    video.waitUntilEncodingReady()

    print(video)