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.
*/
define('SDK_DIR', DIR . '/..'); // Path to the SDK directory
$loader = include SDK_DIR.'/vendor/autoload.php';
date_default_timezone_set('America/Los_Angeles');
use FacebookAds\Object\AdAccount;
use FacebookAds\Object\Campaign;
use FacebookAds\Object\AdSet;
use FacebookAds\Object\AdCreative;
use FacebookAds\Object\Ad;
use FacebookAds\Object\AdPreview;
use FacebookAds\Api;
//use FacebookAds\Logger\CurlLogger;
//try{
$access_token = '';
$ad_account_id = 'act_105478390317505';
$account_id='105478390317505';
$app_secret = 'b2fbcb713f179935d5b4bcfa8c407982';
$page_id = '701194529963043';
$app_id = '2217624105131813';
`<?php /**
*/ define('SDK_DIR', DIR . '/..'); // Path to the SDK directory $loader = include SDK_DIR.'/vendor/autoload.php'; date_default_timezone_set('America/Los_Angeles');
use FacebookAds\Object\AdAccount; use FacebookAds\Object\Campaign; use FacebookAds\Object\AdSet; use FacebookAds\Object\AdCreative; use FacebookAds\Object\Ad; use FacebookAds\Object\AdPreview; use FacebookAds\Api; //use FacebookAds\Logger\CurlLogger; //try{ $access_token = '';
$ad_account_id = 'act_105478390317505';
$account_id='105478390317505';
$app_secret = 'b2fbcb713f179935d5b4bcfa8c407982';
$page_id = '701194529963043';
$app_id = '2217624105131813';
$api = Api::init($app_id, $app_secret, $access_token); //$api->setLogger(new CurlLogger());
$fields = array( ); $params = array( 'objective' => 'PAGE_LIKES', 'status' => 'PAUSED', 'buying_type' => 'AUCTION', 'name' => 'My Campaign', ); $campaign = (new AdAccount($ad_account_id))->createCampaign( $fields, $params ); $campaign_id = $campaign->id; echo '
campaign_id: ' . $campaign_id . "\n\n";
$fields = array( );
$params = array( 'status' => 'PAUSED', 'targeting' => array('geo_locations' => array('countries' => array('US'))), 'daily_budget' => '4000', 'billing_event' => 'IMPRESSIONS', 'bid_amount' => '20', 'campaign_id' => $campaign_id, 'optimization_goal' => 'PAGE_LIKES', 'promoted_object' => array('page_id' => $page_id), 'name' => 'My AdSet1', ); $ad_set = (new AdAccount($ad_account_id))->createAdSet( $fields, $params ); $ad_set_id = $ad_set->id; echo '
ad_set_id: ' . $ad_set_id . "\n\n";
$fields = array( ); $params = array( 'body' => 'Like My Page', 'image_url' => 'http://web-scraping.co.uk/trainer_app/assets/images/ic_logo_trim.png', 'name' => 'My Creative', 'object_id' => $page_id, 'title' => 'My Page Like Ad', ); $creative = (new AdAccount($ad_account_id))->createAdCreative( $fields, $params ); $creative_id = $creative->id; echo '
creative_id: ' . $creative_id . "\n\n";
$fields = array( ); $params = array( 'status' => 'PAUSED', 'adset_id' => $ad_set_id, 'name' => 'My Page Like Ad', 'creative' => array('creative_id' => $creative_id), ); $ad = (new AdAccount($ad_account_id))->createAd( $fields, $params ); $ad_id = $ad->id; echo '
ad_id: ' . $ad_id . "\n\n";
$fields = array( ); $params = array( 'ad_format' => 'DESKTOP_FEED_STANDARD', ); echo json_encode((new Ad($ad_id))->getPreviews( $fields, $params )->getResponse()->getContent(), JSON_PRETTY_PRINT);
/ }catch(Exception $e) { echo $e->getMessage(); print_r($e); }/ ?>`