{"id":47756394,"url":"https://github.com/fbsamples/marketing-api-samples","last_synced_at":"2026-04-03T04:25:24.025Z","repository":{"id":39615797,"uuid":"62191754","full_name":"fbsamples/marketing-api-samples","owner":"fbsamples","description":"Solution samples using the Facebook marketing API.","archived":false,"fork":false,"pushed_at":"2026-03-24T20:35:10.000Z","size":37646,"stargazers_count":54,"open_issues_count":8,"forks_count":22,"subscribers_count":27,"default_branch":"master","last_synced_at":"2026-03-24T20:57:02.896Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fbsamples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"security/__init__.py","support":null}},"created_at":"2016-06-29T03:12:42.000Z","updated_at":"2026-03-23T22:04:44.000Z","dependencies_parsed_at":"2022-09-15T21:41:27.365Z","dependency_job_id":null,"html_url":"https://github.com/fbsamples/marketing-api-samples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fbsamples/marketing-api-samples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbsamples%2Fmarketing-api-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbsamples%2Fmarketing-api-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbsamples%2Fmarketing-api-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbsamples%2Fmarketing-api-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fbsamples","download_url":"https://codeload.github.com/fbsamples/marketing-api-samples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fbsamples%2Fmarketing-api-samples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31333234,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T03:20:36.090Z","status":"ssl_error","status_checked_at":"2026-04-03T03:20:35.133Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-03T04:25:23.056Z","updated_at":"2026-04-03T04:25:24.018Z","avatar_url":"https://github.com/fbsamples.png","language":"JavaScript","readme":"** THIS REPO HAS BEEN ARCHIVED AND IS NO LONGER BEING ACTIVELY MAINTAINED **\n\n# Facebook Marketing API Samples (Muse)\nFacebook Marketing API Samples is a package of samples that demonstrate how to\nuse the Marketing API SDK to implement actual use cases.\n\n## Requirements\n- Python 2.7\n- pip [install guide](https://pip.pypa.io/en/stable/installing/)\n- PostgreSQL [install guide](https://wiki.postgresql.org/wiki/Detailed_installation_guides)\n\n## Setting up Facebook Marketing API Samples\n- Install virtualenv and virtualenvwrapper\n\n\t\t\tsudo pip install virtualenv\n\t\t\tsudo pip install virtualenvwrapper --ignore-installed\n\n- Add these lines to `~/.bashrc` or `~/.bash_profile` depending on your system\n\n\t\t\texport WORKON_HOME=~/envs\n\t\t\tsource /usr/local/bin/virtualenvwrapper.sh\n\n- Close and reopen terminal. Make a new virtual environment called `muse`:\n\n\t\t\tmkvirtualenv muse -a /your/path/to/muse\n\n- From now on you can switch to this environment by using the `workon` command:\n\n\t\t\tworkon muse\n\n- Install muse dependencies:\n\n\t\t\tpip install -r requirements.txt\n\n- Update the setting file:\n\n\t\t\tworkon muse\n\t\t\tvim $VIRTUAL_ENV/bin/postactivate\n\n- Add this to `postactivate` file:\n\n\t\t\texport DJANGO_SETTINGS_MODULE=\"muse.settings\"\n\t\t\texport FACEBOOK_APP_ID=\"app_id for an app that supports https://localhost:8000\"\n\t\t\texport FACEBOOK_APP_SECRET=\"the app secret for the above app\"\n\n- Samples metadata is stored in and served from a database. To get sample metadata inserted into your local database run this command:\n\n\t\t\tpython manage.py migrate\n\n- Before you can run the site, the project uses [npm](https://www.npmjs.com/) and a [gulp](http://gulpjs.com/) process to build the JavaScript files for the UI components. The `package.json` script contains a `postinstall` task that does the building. To install and initialize this, make sure you have [Node.js](https://nodejs.org/en/) and npm installed, then run\n\n\t\t\tnpm install\n\n- Finally, run Muse site locally:\n\n\t\t\tpython manage.py runsslserver\n\n- Open your browser and go to `https://localhost:8000` to see the running site\n\n## How Facebook Marketing API Samples works\nEach sample is a self contained Python script located in muse/samples/samplecode. This script doesn't need to be concerned with user input validation, login, or displaying results. It only needs to be concerned with the solution it provides. The goal is that the marketing developer can copy this script and run it in their own environment using only python.\n\nTo let developers discover and play with samples, the functionality is exposed online using a Django view and associated form and template.\n\nTo display a gallery of samples and dispatch requests to the sample view, we also need some metadata about the sample including name, description, sample view name, and a unique string id that becomes the sample's URL on the site.\n\nSo each sample consists of:\n\n1. Sample script containing the solution code that developers can use\n2. Sample Django view, form and html template\n3. Sample metadata\n\n### Writing a New Sample Script\nCreate a new python module in `samples/samplecode`. Write your sample code using the Python Ads API SDK. Assume the SDK is already initialized with the user's access token so you don't need to worry about that.\n\nWrite one main class that is named with your sample name e.g. `AwesomeSolutionSample`. This class should have one method that is your sample's entry point. It can have any other methods or attributes that make sense but they are not to be called by external code. Be thoughtful in factoring your code into classes and methods to make more readable and reusable.\n\nUse python docstrings at the module level to provide information that will be displayed at the top of your sample's web page. Start with a title then an overview of what the sample does. Include links to relevant developer docs.\n\nUse Python docstrings at the class and method level to provide information that will be displayed at the bottom of your sample's web page as code documentation.\n\n### Writing a New Sample View\nCreate a new python module in `samples/views`. In this module, write a Django class-based view and its associated form.\n\nThe view needs to support GET so that a user can view your sample page. Most samples will also have a form to collect user input, such as which ad account to use, so the view needs to also support POST.\n\nIn MUSE, we collected the common code required for each sample into common View and Form classes:\n\n- SampleBaseView in `samples/views/sample.py`\n- ComponentForm in `common/components/component_form.py`\n\nThe `ComponentForm` will implement form wide validations and other form level logic that should be shared across samples. The `SampleBaseView` will use the base sample template from `muse/samples/templates/samples/sample_form.html`. This templates will simply render the form object from your sample view, so you don't have to write your own template. If you need to customize you can:\n\n- Define `BUTTON_TEXT` class variable at your sample view class to override the text appearing on the sample's run button. Or\n- Define `TEMPLATE` class variable at your sample view class to change the default sample form template.\nCheckout the Carousel App Ad sample as a reference.\n\n## Add Sample Metadata\nTo show the sample in the list view, you need to add the sample metadata. Edit and add the following migration code into the file `dash/migrations/9999_auto_samples_metadata.py`:\n\n\t\tSample.objects.create(\n\t\t\tview_class=\"\u003cSAMPLE_VIEW_CLASS_NAME\u003e\",\n\t\t\tdescription=\"\u003cSAMPLE_VIEW_DESCRIPTION\u003e\",\n\t\t\tview_module=\"\u003cSAMPLE_VIEW_MODULE_NAME\u003e\",\n\t\t\tseo_description=\"\u003cSAMPLE_VIEW_DESCRIPTION\u003e\",\n\t\t\tfriendly_name=\"\u003cSAMPLE_VIEW_FRIENDLY_NAME\u003e\",\n\t\t\troles_to_check=\"\",\n\t\t\tid=\"\u003cURL_EXTENSION\u003e\")\n\nAfter editing the migration file, run the migration:\n\n\t\tpython manage.py migrate\n\nFind the sample you just created in the sample list `https://127.0.0.1:8000/samples`.\n\n## License\nPlease refer to the LICENSE file.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffbsamples%2Fmarketing-api-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffbsamples%2Fmarketing-api-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffbsamples%2Fmarketing-api-samples/lists"}