/** * @param RequestInterface $request * @return string */ protected function processUrl(RequestInterface $request) { $request = clone $request; // Force production (without prod.) $request->setDomain(static::PRODUCTION_TIER_DOMAIN); $components = explode('/', $request->getPath()); foreach ($components as &$component) { $varname = $this->getPlaceholderByValue($component); if ($varname !== null) { $component = static::getPlaceholder($varname); } } $request = clone $request; $request->setPath(implode('/', $components)); return parent::processUrl($request); }
$access_token = null; $app_id = null; $app_secret = null; // should begin with "act_" (eg: $account_id = 'act_1234567890';) $account_id = null; define('SDK_DIR', __DIR__ . '/..'); // Path to the SDK directory $loader = (include SDK_DIR . '/vendor/autoload.php'); // Configurations - End if (is_null($access_token) || is_null($app_id) || is_null($app_secret)) { throw new \Exception('You must set your access token, app id and app secret before executing'); } if (is_null($account_id)) { throw new \Exception('You must set your account id before executing'); } use FacebookAds\Api; use FacebookAds\Logger\CurlLogger; Api::init($app_id, $app_secret, $access_token); // Create the CurlLogger $logger = new CurlLogger(); // To write to a file pass in a file handler // $logger = new CurlLogger(fopen('test','w')); // If you need to escape double quotes, use the following - useful for docs $logger->setEscapeLevels(1); // Hide target ids and tokens $logger->setShowSensitiveData(false); // Attach the logger to the Api instance Api::instance()->setLogger($logger); use FacebookAds\Object\AdAccount; use FacebookAds\Object\Fields\AdAccountFields; $account = (new AdAccount($account_id))->read(array(AdAccountFields::ID, AdAccountFields::NAME, AdAccountFields::ACCOUNT_STATUS));