Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
stcheng authored Aug 21, 2024
2 parents b54d9cb + 0c2167b commit 849007e
Show file tree
Hide file tree
Showing 503 changed files with 14,695 additions and 253 deletions.
40 changes: 21 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PATH
remote: .
specs:
facebookbusiness (0.15.0.2)
facebookbusiness (20.0.0)
concurrent-ruby (~> 1.1)
countries (>= 3, < 6)
faraday (~> 2.6)
faraday-multipart (~> 1.0)
faraday-multipart (~> 1.0.4)
json (~> 2.6)
money (~> 6.13)

Expand All @@ -16,30 +16,29 @@ GEM
awesome_print (1.9.2)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.2.0)
concurrent-ruby (1.3.3)
coolline (0.5.0)
unicode_utils (~> 1.4)
countries (3.1.0)
i18n_data (~> 0.11.0)
sixarm_ruby_unaccent (~> 1.1)
unicode_utils (~> 1.4)
countries (5.7.2)
unaccent (~> 0.3)
diff-lcs (1.5.0)
dotenv (2.8.1)
faraday (2.7.4)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday (2.9.2)
faraday-net_http (>= 2.0, < 3.2)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (3.0.2)
i18n (1.12.0)
faraday-net_http (3.1.0)
net-http
i18n (1.14.5)
concurrent-ruby (~> 1.0)
i18n_data (0.11.0)
json (2.6.3)
json (2.7.2)
method_source (1.0.0)
minitest (5.14.4)
money (6.16.0)
money (6.19.0)
i18n (>= 0.6.4, <= 2)
multipart-post (2.3.0)
multipart-post (2.4.1)
net-http (0.4.1)
uri
parallel (1.22.1)
parser (3.2.0.0)
ast (~> 2.4.1)
Expand All @@ -52,7 +51,8 @@ GEM
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.6.2)
rexml (3.2.5)
rexml (3.3.3)
strscan
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
Expand All @@ -78,13 +78,15 @@ GEM
rubocop-ast (1.24.1)
parser (>= 3.1.1.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
sixarm_ruby_unaccent (1.2.0)
strscan (3.1.0)
unaccent (0.4.0)
unicode-display_width (1.8.0)
unicode_utils (1.4.0)
uri (0.13.0)

PLATFORMS
arm64-darwin-22
x86_64-linux

DEPENDENCIES
awesome_print (~> 1.8)
Expand Down
4 changes: 2 additions & 2 deletions examples/AdAccountAdSetsPostAdSetCreateCpa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
name: 'A CPA Ad Set',
campaign_id: '<adCampaignLinkClicksID>',
daily_budget: '5000',
start_time: '2024-04-08T11:26:05-0700',
end_time: '2024-04-15T11:26: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.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
name: 'A CPA Ad Set optimized for App Events',
campaign_id: '<adCampaignAppInstallsID>',
daily_budget: '300',
start_time: '2024-04-08T11:26:49-0700',
end_time: '2024-04-15T11:26:49-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.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
adsets = ad_account.adsets.create({
name: 'My First AdSet',
lifetime_budget: '20000',
start_time: '2024-04-08T11:25:19-0700',
end_time: '2024-04-15T11:25:19-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.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
adsets = ad_account.adsets.create({
name: 'My First Adset',
daily_budget: '2000',
start_time: '2024-04-01T11:26:23-0700',
end_time: '2024-04-08T11:26:23-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 @@ -33,8 +33,8 @@
adsets = ad_account.adsets.create({
name: 'My First Adset',
lifetime_budget: '20000',
start_time: '2024-04-01T11:26:32-0700',
end_time: '2024-04-11T11:26:32-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.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
adsets = ad_account.adsets.create({
name: 'My First Adset',
lifetime_budget: '20000',
start_time: '2024-04-01T11:26:40-0700',
end_time: '2024-04-11T11:26:40-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.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
ad = FacebookAds::Ad.get(id)
leadss = ad.leads({
fields: { },
filtering: [{'field':'time_created','operator':'GREATER_THAN','value':1711391704}],
filtering: [{'field':'time_created','operator':'GREATER_THAN','value':1717544918}],
})
2 changes: 1 addition & 1 deletion examples/AdsPixelEventsPost.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@

ads_pixel = FacebookAds::AdsPixel.get(id)
events = ads_pixel.events.create({
data: [{'event_name':'PageView','event_time':1711995835,'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'}}],
})
79 changes: 79 additions & 0 deletions examples/PROMOTE_YOUR_PAGE.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.

# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.

require 'facebookbusiness'

app_id = '<APP_ID>'
account_id = 'act_<ACCOUNT_ID>'
page_id = '<PAGE_ID>'
ads_image_hash = '<IMAGE_HASH>'
page_link = 'https://facebook.com/<PAGE_ID>'
access_token = '<ACCESS_TOKEN>'

FacebookAds.configure do |config|
config.access_token = access_token
config.log_api_bodies = true
config.crash_logging_enabled = false
end


# Step 1: Create an ad campaign

ad_account = FacebookAds::AdAccount.get(account_id)
campaign = ad_account.campaigns.create({
objective: 'OUTCOME_TRAFFIC',
status: 'PAUSED',
buying_type: 'AUCTION',
name: 'My Campaign',
special_ad_categories: [],
})
campaign_id = campaign.id
print 'campaign_id:', campaign_id


# Step 2: Under the campaign, create an ad set with some buying options

ad_account = FacebookAds::AdAccount.get(account_id)
ad_set = ad_account.adsets.create({
status: 'PAUSED',
targeting: {'geo_locations': {'countries': ['US']}},
daily_budget: '100',
billing_event: 'IMPRESSIONS',
bid_amount: '20',
campaign_id: campaign_id,
optimization_goal: 'REACH',
promoted_object: {'page_id': page_id},
name: 'My AdSet',
})
ad_set_id = ad_set.id
print 'ad_set_id:', ad_set_id


# Step 3: Create an ad creative with your amazing design
# This ad creative is promoting your page

ad_account = FacebookAds::AdAccount.get(account_id)
creative = ad_account.adcreatives.create({
name: 'Creative',
object_story_spec: {'page_id':page_id,'link_data':{'image_hash':ads_image_hash,'link':page_link,'message':'Creative message','call_to_action':{'type':'LIKE_PAGE','value':{'page':page_id}}}},
degrees_of_freedom_spec: {'creative_features_spec': {'standard_enhancements': {'enroll_status': 'OPT_IN'}}},
})
creative_id = creative.id
print 'creative_id:', creative_id


# Step 4: Create an ad under your ad set with your ad creative

ad_account = FacebookAds::AdAccount.get(account_id)
ad = ad_account.ads.create({
status: 'PAUSED',
adset_id: ad_set_id,
name: 'My Ad',
creative: {'creative_id': creative_id},
ad_format: 'DESKTOP_FEED_STANDARD',
})
ad_id = ad.id
print 'ad_id:', ad_id
1 change: 1 addition & 0 deletions lib/facebook_ads/ad_objects/ad.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Ad < AdObject
field :conversion_specs, { list: 'ConversionActionQuery' }
field :created_time, 'datetime'
field :creative, 'AdCreative'
field :creative_asset_groups_spec, 'AdCreativeAssetGroupsSpec'
field :demolink_hash, 'string'
field :display_sequence, 'int'
field :effective_status, { enum: -> { EFFECTIVE_STATUS }}
Expand Down
Loading

0 comments on commit 849007e

Please sign in to comment.