facebook / facebook-business-sdk-codegen Goto Github PK
View Code? Open in Web Editor NEWCodegen project for our business SDKs
Home Page: https://developers.facebook.com/docs/business-sdk
License: Other
Codegen project for our business SDKs
Home Page: https://developers.facebook.com/docs/business-sdk
License: Other
16.15.0
8.5.5
Be able to use strongly-typed programming without type casting when creating API resources, as it was possible before v13
I expect existing code using facebook-java-business-sdk which creates AdSet in particular to compile without errors
There are no breaking changes introduced in v13 changelog related to AdSet creation
https://developers.facebook.com/docs/graph-api/changelog/version13.0
Compilation error due to:
before commit
public static class APIRequestCreateAdSet extends APIRequest<AdSet>
public static class APIRequestCreateAdSet extends APIRequest<APINode>
before commit
public APIRequestCreateAdSet setBillingEvent (AdSet.EnumBillingEvent billingEvent)
public APIRequestCreateAdSet setBillingEvent (EnumBillingEvent billingEvent)
There are more enums which suffered from additional enum definition copies added
There are more entities which lost strongly-typed api
One can observe the same in node.js sdk returning Promise<AbstractObject>
Try to compile examples
Restore return type back to "AdSet" in spec
Restore "node" property on "adaccountadsets_billing_event_enum_param" back to "AdSet" in spec
I'd be happy to create PR, but commit tells the spec was "Automitically generate from our internal API framework." which I don't have access to.
I can confirm java sdk is fully compilable after mentioned changes
I might be missing something, since I just joined a java project and learning java for 5 days and fb business api for 1.5 days, but it'd be so nice to leave the code as is without typecasting.
Following my pull request : #75
I have checked the different typed versions ( java
, python
, php
, ruby
)
I think the patch in the file SDKCodegen.json is not working as expected during the SDK generation.
"LeadgenForm": {
"$.fields[?(@.name=='tracking_parameters')]": {
"keyvalue": true
}
},
โ JAVA
Got = Expected
private List<KeyValue> mTrackingParameters = null;
๐ PHP
Got :
'tracking_parameters' => 'list<map<string, string>>',
Expected
'tracking_parameters' => 'list<KeyValue>',
๐ PYTHON
Got :
'tracking_parameters': 'list<map<string, string>>',
Expected
'tracking_parameters': 'list<KeyValue>',
๐ RUBY
Got :
field :tracking_parameters, { list: 'hash' }
Expected :
field :tracking_parameters, { list: 'KeyValue' }
I don't know yet if the other patches are working properly for other adobjects.
Best Regards
python environment
I want to create ads with site links using the 'creative_sourcing_spec' key in Adcreative
Ads created with sitelinks
Status: 400
Response:
{
"error": {
"message": "(#10) Application does not have permission for this action",
"type": "OAuthException",
"code": 10,
"fbtrace_id": "A4tpKntRJhpF3ww0FQjvqyH"
}
}
Try creating an ad using creative_sourcing_spec
ad_account_id = 'act_70xxxxx'
FacebookAdsApi.init(access_token=fb_access_token,api_version='v20.0')
sitelinks = [
{
'site_link_title':'Link 1 Title',
'site_link_url':'https://example.com/link1'
},
{
'site_link_title':'Link 2 Title',
'site_link_url':'https://example.com/link2'
},
{
'site_link_title':'Link 3 Title',
'site_link_url':'https://example.com/link3'
}
]
promotion_metadata = [
{
'end_date': 1627776000,
#'id': 'id_string',# valid offer_id
'promotion_source': 'ADVERTISER_INPUT'
'promotion_type': 'PERCENTAGE_OFF',
'promotion_value': 10.0,
'required_code': 'SUMMER10',
'start_date': 1625097600,
}
]
creative_sourcing_spec = {
"site_links_spec": sitelinks,
"promotion_metadata_spec": promotion_metadata,
"source_url": 'https://www.digital.de'
}
# Create the ad creative
creative_params = {
'name': 'Your Ad Creative Name',
'object_story_spec': {
'page_id': page_id ,
'instagram_actor_id':instagram_page_id,
'link_data': {
'link': 'https://www.digital.de',
'message': 'Testing Your ad message',
'name': 'Testing Your headline',
'description': 'Testing Your ad description',
}
},
'contextual_multi_ads': {
"enroll_status": "OPT_IN"
},
"degrees_of_freedom_spec": {
"creative_features_spec": {
"standard_enhancements": {
"enroll_status": "OPT_IN"
}
}
},
'creative_sourcing_spec': creative_sourcing_spec
}
ad_creative = AdAccount(ad_account_id).create_ad_creative(fields=[], params=creative_params)
ad_params = {
'name': 'Testing Site Links and Offers Ad Name',
'adset_id': 238xxxxxxxx,
'creative': {'creative_id': ad_creative['id']},
'status': 'PAUSED',
}
AdAccount(ad_account_id).create_ad(fields=[], params=ad_params)
Feature Request: [name of my feature request]
Access the ads library API (https://www.facebook.com/ads/library/api) through the SDK so that my users can see ads from companies similar to theirs and build better ads.
v18.18.2
10.2.0
Tried under both windows & ubuntu distribution
Successfully run the README.md steps from a fresh repository
Generate the clients !!
Failure when running npm run build command. Getting "src/ doesn't exist" error message instead.
Since 12eef67, it seems this folder does not exist anymore and there is no CodeGenerator.js file to be found anywhere in the repository.
Am I missing something very obvious or is there an actual issue? Thanks for your help!!
$ npm install
up to date in 2s
$ npm run build
> [email protected] build
> babel src/ -d lib/
src/ doesn't exist
Describe your dev environment here, giving as many details as possible. If you have them, make sure to include:
16.16.0
8.11.0
What do you want to achieve?
Get correct type for targeting_optimization_types
What do you expect to happen?
According to documentation, targeting_optimization_types has type listKeyValue:string,int32, so type in codegen specs should be list
There are 3 objects that uses this field:
What actually happened?
Current type for targeting_optimization_types is map<string, int>
Because of that, targeting_optimization_types could not be mapped properly. For example, one issue was reported in python sdk project link
Please provide a code sample, as well as any additional details, to help us track down the issue. If you can provide a link to a test project that allows us to reproduce the issue, this helps us immensely in both the speed and quality of the fix.
{
"name": "targeting_optimization_types",
"type": "map<string, int>"
}
should be changed to:
{
"name": "targeting_optimization_types",
"type": "list<map>"
}
14.18.2
7.24.2
I want to generate the python SDK for v14
I would expect changes related to schema/fields in adobjects.
lots of files deleted and three of them modified. The three modifications are simply replacing 13.0.0
for 14.0.0
. It doesn't seem that these changes are correct.
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: examples/AdAccountActivityNode.py
deleted: examples/AdAccountAdCreativesEdge.py
deleted: examples/AdAccountAdCreativesPost.py
deleted: examples/AdAccountAdCreativesPost2CreateAdCreativeLinkAd.py
deleted: examples/AdAccountAdCreativesPost2CreateLinkAdCallToActionAppInstall.py
deleted: examples/AdAccountAdCreativesPost2CreateLinkAdImageCrop.py
deleted: examples/AdAccountAdCreativesPost2CreateMAIDPA.py
deleted: examples/AdAccountAdCreativesPost2CreateVideoLeadAd.py
deleted: examples/AdAccountAdCreativesPost2CreateVideoPageLikeAd.py
deleted: examples/AdAccountAdCreativesPost3CreateAdCreativePageLike.py
deleted: examples/AdAccountAdCreativesPost3CreateAssetFeedSpec.py
deleted: examples/AdAccountAdCreativesPost3CreateCarouselCallToActionAppInstall.py
deleted: examples/AdAccountAdCreativesPost3CreateDynamicAdCustomization.py
deleted: examples/AdAccountAdCreativesPostCreateAdCreative.py
deleted: examples/AdAccountAdCreativesPostCreateAdCreativeCanvas.py
deleted: examples/AdAccountAdCreativesPostCreateAdCreativeCustomizationCanvasDV.py
deleted: examples/AdAccountAdCreativesPostCreateAdCreativeCustomizationCanvasImage.py
deleted: examples/AdAccountAdCreativesPostCreateAdCreativeCustomizationCanvasVideo.py
deleted: examples/AdAccountAdSetsPost2CreateMAIA.py
deleted: examples/AdAccountAdSetsPostAdSetCreateCpa.py
deleted: examples/AdAccountAdSetsPostAdSetCreateCpaAppEvents.py
deleted: examples/AdAccountAdSetsPostBehaviorTargeting.py
deleted: examples/AdAccountAdSetsPostBidMultiplier.py
deleted: examples/AdAccountAdSetsPostCreateAdSet.py
deleted: examples/AdAccountAdSetsPostCreateAudienceNetwork.py
deleted: examples/AdAccountAdSetsPostDailyBudget20.py
deleted: examples/AdAccountAdSetsPostDemographicTargeting.py
deleted: examples/AdAccountAdSetsPostInterestTargeting.py
deleted: examples/AdAccountAdSetsPostLifetimeBudget200Duration10Days.py
deleted: examples/AdAccountAdSetsPostOfferClaim.py
deleted: examples/AdAccountAdSetsPostOptimizePostEngagement.py
deleted: examples/AdAccountAdSetsPostPageLikes.py
deleted: examples/AdAccountAdSetsPostPlacementTargeting.py
deleted: examples/AdAccountAdSetsPostReach.py
deleted: examples/AdAccountAdVideosPost.py
deleted: examples/AdAccountAdsPixelEdgeGetPixelCode.py
deleted: examples/AdAccountAdsPixelsPost.py
deleted: examples/AdAccountAdsPost.py
deleted: examples/AdAccountAdsPostAdsRedownload.py
deleted: examples/AdAccountAdsPostOfferClaim.py
deleted: examples/AdAccountAdsPostTrackingPostEngagement.py
deleted: examples/AdAccountCampaignsEdge.py
deleted: examples/AdAccountCampaignsPostConversions.py
deleted: examples/AdAccountCampaignsPostEventResponses.py
deleted: examples/AdAccountCampaignsPostLeadGen.py
deleted: examples/AdAccountCampaignsPostLinkClicks.py
deleted: examples/AdAccountCampaignsPostLocalAwareness.py
deleted: examples/AdAccountCampaignsPostMAIA.py
deleted: examples/AdAccountCampaignsPostMAIDPA.py
deleted: examples/AdAccountCampaignsPostOfferClaims.py
deleted: examples/AdAccountCampaignsPostPageLikes.py
deleted: examples/AdAccountCampaignsPostPostEngagement.py
deleted: examples/AdAccountCampaignsPostStoreCampaign.py
deleted: examples/AdAccountCampaignsPostVideoViews.py
deleted: examples/AdAccountCustomAudiencesEdge.py
deleted: examples/AdAccountCustomAudiencesEdgeDataSourceSubtype.py
deleted: examples/AdAccountCustomAudiencesPostCreateCustomAudience.py
deleted: examples/AdAccountCustomAudiencesPostDynamicEventValueBasedLookalikeCustomAudience.py
deleted: examples/AdAccountCustomAudiencesPostDynamicValueBasedLookalikeCustomAudience.py
deleted: examples/AdAccountCustomAudiencesPostPlatformCustomAudienceMACARule.py
deleted: examples/AdAccountCustomAudiencesPostPlatformECAExclusions.py
deleted: examples/AdAccountCustomAudiencesPostPlatformECAMultiFilters.py
deleted: examples/AdAccountCustomAudiencesPostPlatformECAMultiPages.py
deleted: examples/AdAccountCustomAudiencesPostPlatformEngagementCustomAudience.py
deleted: examples/AdAccountCustomAudiencesPostPlatformWebsiteCustomAudience.py
deleted: examples/AdAccountCustomAudiencesPostValueBasedCustomAudience.py
deleted: examples/AdAccountCustomAudiencesPostValueBasedLookalikeCustomAudience.py
deleted: examples/AdAccountGeneratePreviewsEdge.py
deleted: examples/AdAccountGeneratePreviewsEdgeDesktopWithStoryId.py
deleted: examples/AdAccountGeneratePreviewsEdgeInstagramStandards.py
deleted: examples/AdAccountGeneratePreviewsEdgeMaiaWithObjectStorySpec.py
deleted: examples/AdAccountNode.py
deleted: examples/AdAccountProductAudiencesPostIphoneViewNoPurchase.py
deleted: examples/AdAccountProductAudiencesPostNoPurchase.py
deleted: examples/AdAccountReachEstimate.py
deleted: examples/AdCampaignActivityNode.py
deleted: examples/AdCampaignGroupActivityNode.py
deleted: examples/AdCampaignGroupAdsEdge.py
deleted: examples/AdCampaignGroupAdsEdgeAdgroupsWithStatusArchived.py
deleted: examples/AdCampaignGroupAdsetsEdge.py
deleted: examples/AdCampaignNode.py
deleted: examples/AdCampaignPost.py
deleted: examples/AdCampaignPostAdsetUpdateCpa.py
deleted: examples/AdCreativeCreativeInsightsEdge.py
deleted: examples/AdCreativeNode.py
deleted: examples/AdCreativeNodeRead.py
deleted: examples/AdCreativeNodeReadInstagramPermalinkUrl.py
deleted: examples/AdCreativePreviewsEdge.py
deleted: examples/AdCreativePreviewsEdgePreview.py
deleted: examples/AdCreativePreviewsEdgePreviewDynamicAds.py
deleted: examples/AdCreativePreviewsEdgePreviewDynamicAdsWithCustomizations.py
deleted: examples/AdgroupActivityNode.py
deleted: examples/AdgroupLeadsEdgeAdgroupLeads.py
deleted: examples/AdgroupLeadsEdgeAdgroupLeadsDPA.py
deleted: examples/AdgroupLeadsEdgeAdgroupLeadsFiltered.py
deleted: examples/AdgroupPost.py
deleted: examples/AdgroupPostUpdateStatus.py
deleted: examples/AdsInsightsEdgeAdCampaignInsights.py
deleted: examples/AdsInsightsEdgeStoreVisitsAdCampaignInsights.py
deleted: examples/AdsPixelEventsPost.py
deleted: examples/AdsPixelEventsPostCustom.py
deleted: examples/AdsPixelSharedAccountsEdge.py
deleted: examples/AdsPixelSharedAccountsPost.py
deleted: examples/AdsPixelSharedAgenciesEdge.py
deleted: examples/BusinessOwnedProductCatalogsPostDestinationCatalog.py
deleted: examples/BusinessOwnedProductCatalogsPostFlightCatalog.py
deleted: examples/BusinessOwnedProductCatalogsPostHotelCatalog.py
deleted: examples/BusinessOwnedProductCatalogsPostProductCatalog.py
deleted: examples/CustomAudienceDelete.py
deleted: examples/CustomAudienceNode.py
deleted: examples/CustomAudienceNodeReadRule.py
deleted: examples/CustomAudiencePost.py
deleted: examples/CustomAudienceUsersPost.py
deleted: examples/CustomAudienceUsersPostCrossPlatform.py
deleted: examples/MultiPageFeedCreateThenDelete.py
deleted: examples/MultiPromoteYourPage.py
deleted: examples/OfflineConversionsCreateOfflineSet.py
deleted: examples/PageFeedEdge.py
deleted: examples/PageFeedPost.py
deleted: examples/PageFeedPostFeedImageDeepLink.py
deleted: examples/PageNode.py
deleted: examples/PageNodePageSearch.py
deleted: examples/PagePhotosEdge.py
deleted: examples/PagePhotosPost.py
deleted: examples/PagePictureEdge.py
deleted: examples/PagePostCommentsEdge.py
deleted: examples/PagePostCommentsPost.py
deleted: examples/PagePostDelete.py
deleted: examples/PagePostNode.py
deleted: examples/PagePostPost.py
deleted: examples/PagePostsEdge.py
deleted: examples/PagePostsEdgePagePostCreateCarousel.py
deleted: examples/PageRolesEdge.py
deleted: examples/PageSubscribedAppsPost.py
deleted: examples/ProductCatalogEventStatsEdge.py
deleted: examples/ProductCatalogHotelsPost.py
deleted: examples/ProductCatalogHotelsPostUpdateHotelsCatalogSettings.py
deleted: examples/ProductCatalogProductFeedsPostProductFeed.py
deleted: examples/ProductCatalogProductSetsPostHotelSet.py
deleted: examples/ProductCatalogProductSetsPostProductSet.py
deleted: examples/UserAccountsEdge.py
deleted: examples/UserAdAccountsEdge.py
deleted: examples/UserLeadGenInfoNode.py
deleted: examples/UserNode.py
deleted: examples/VideoThumbnailsEdge.py
modified: facebook_business/__init__.py
modified: facebook_business/apiconfig.py
deleted: facebook_business/docs_runner/__init__.py
deleted: facebook_business/docs_runner/doc_runner.py
deleted: facebook_business/docs_runner/get_version.py
modified: setup.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
compiled.json
no changes added to commit (use "git add" and/or "git commit -a")
cloned facebook-python-business-sdk
repository, changed 13.0.0
for 14.0.0
in setup.py
moved facebook-python-business-sdk
to sdk/servers/python/release
cloned and this repository, installed dependencies with npm i
and then built it with npm run build
.
ran node lib/CodeGenerator.js python
I'm willing to dedicate more time working on this ๐ช, but would need some guidance from facebook team to get things right
Is there a way to update the JSON defs for a new API version? for example currently, this package only support v14 but v15 is available. I would like to generate Python SDK code using this package so I can submit it downstream to resolve hard blockers like this one. However, I'm not sure how to autogenerate. I looked around the repo and didn't find something which can achieve this. Could you help?
I guess more generally, as a consumer of this package, what are my options for staying up to date with API changes while still using an SDK generated by this package?
Describe your dev environment here, giving as many details as possible. If you have them, make sure to include:
20.11.1
10.2.4
6.26.0 (babel-core 6.26.3)
I want to run CodeGenerator.js as the README.md described.
The command I used to run:
CodeGenerator.js
successfully executed.
xxxxxx@xxhost:~/GitProjSrc/facebook-business-sdk-codegen$ pwd
/home/xxxxxx/GitProjSrc/facebook-business-sdk-codegen
xxxxxx@xxhost:~/GitProjSrc/facebook-business-sdk-codegen$ npm run build && node lib/CodeGenerator.js java
> [email protected] build
> babel src/ -d lib/
src/ doesn't exist
xxxxxx@xxhost:~/GitProjSrc/facebook-business-sdk-codegen$ npm run build
> [email protected] build
> babel src/ -d lib/
src/ doesn't exist
npm run build && node lib/CodeGenerator.js java
Feature Request: [name of my feature request]
Be able to fully validate and describe the API, align to official references documentation
I expect a field like filtering to contain list<FilterObject>
or list<AdRuleFilter>
and not list<Object>
FilterObject:
{
"apis": [],
"fields": [
{
"name": "field",
"type": "string"
},
{
"name": "operator",
"type": "Filters_operator"
},
{
"name": "value",
"type": "Object"
}
]
}
Ads/insights/filtering:
{
"name": "filtering",
"required": false,
"type": "list<FilterObject>"
},
Thanks
facebook/php-ads-sdk": "5.0.*
I want to create new Creative while creating a new ad. If it fails then returns specific message returned from FB API.
Speicifc errpr message return from FB API like "The image couldn't be downloaded. Please wait a few minutes and try again."
What do you expect to happen?
"array_key_exists() expects parameter 2 to be array, null given".
What actually happened? Can you provide a stack trace?
{ "error": { "message": "Invalid parameter", "type": "OAuthException", "code": 100, "error_data": "null", "error_subcode": 1487833, "is_transient": true, "error_user_title": "Image wasn't downloaded", "error_user_msg": "Your image, https://someimage.png, couldn't be downloaded. Please wait a few minutes and try again.", "fbtrace_id": "AGIA_kW9Khu9XO05piwiXuw" } }
We can't provide token and other details for securoty reasons. You can just try to create a new creative by using following payload.
Payload
{ "access_token": "XXX", "object_type": "SHARE", "object_story_spec": { "page_id": "XXX", "link_data": { "message": "Some message", "link": "https://fb.me/", "name": "test", "picture": "https://storage.googleapis.com/facebook-prod-f655/prod/Xes0M1599608679sC4Qj.png", "description": "Some descriotion", "call_to_action": { "type": "LEARN_MORE", "value": { "lead_gen_form_id": "XXX" } } } } }
Now, whenever a exception occurs getData(); method not handling that properly and not returning appropriate error message.
API call
$adAccount = new AdAccount('act_<ad_account_id>'');
$creative = $adAccount->createAdCreative([], $payload)->getData();
This function is calling createAdCreative() method in FacebookAds\Object\AdAccount class
public function createAdCreative(array $fields = array(), array $params = array(), $pending = false) {
// Code stuff
}
It looks like the methods for creating, updating, and deleting users assigned to ad accounts were removed in bbc4156, even though they are still listed in the documentation: https://developers.facebook.com/docs/marketing-api/reference/ad-account/users/
Will those be restored, or did I miss an announcement to deprecate those?
Describe your dev environment here, giving as many details as possible. If you have them, make sure to include:
15.14.0
7.7.6
What do you want to achieve?
I want to run CodeGenerator.js
as the README.md
described.
The command I used to run: npm run build && node lib/CodeGenerator.js python
What do you expect to happen?
CodeGenerator.js
successfully executed.
Error: ENOENT: no such file or directory, open '/Users/james/Downloads/programmation/sdk/servers/python/release/setup.py'
What actually happened? Can you provide a stack trace?
It is not able to find the sdk folder. In fact, these are the folders named sdk
: (find . -name "sdk" -type d
)
./templates/java/examples/src/main/java/com/facebook/ads/sdk
./templates/java/src/main/java/com/facebook/ads/sdk
Also, it is trying to access the parent folder of the repo. (the cwd is: /Users/james/Downloads/programmation/facebook-business-sdk-codegen
)
Taking a look at how this path is generated, the path is written inapi_specs/version_path.json
, and src/common/Utils.js: loadDefaultSDKVersion
went 3 directories back, but __dirname
is facebook-business-sdk-codegen/lib/common
.
What are the steps necessary to reproduce this issue?
npm install && npm run build && node lib/CodeGenerator.js python
Please provide a code sample, as well as any additional details, to help us track down the issue. If you can provide a link to a test project that allows us to reproduce the issue, this helps us immensely in both the speed and quality of the fix.
Note: Remember to format your code for readability:
npm install && npm run build && node lib/CodeGenerator.js python
I'm using the Java Business sdk v10.0.1.
Use a call to action type of CALL_NOW, as shown in examples here:
https://developers.facebook.com/docs/marketing-api/guides/event-ads#create
SDKs contain an enum value of CALL_NOW in EnumType for AdCreativeLinkDataCallToAction
The enum_types.json file in this project doesn't contain the CALL_NOW call-to-action enum value.
Related to this, the Java Business SDK method AdCreativeLinkDataCallToAction.setFieldType
has only one implementation where the first argument is the EnumType. A different solution might be to include an overloaded method in the SDK with a String type argument instead.
Also reported here
facebook/facebook-java-business-sdk#338
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.