In the newest version of the API,
v201201, we’ve added a feature to streamline the syncing of information in your DFP network to another system. Previously, this was possible but required repeatedly downloading the same objects to see if they had been modified. Now, a new PQL field exists,
lastModifiedDateTime, which can be used to return objects based on their modification dates. Below is a PHP example that uses the
latest client library to display all line items modified in the past 30 days.
// Get the LineItemService.
$lineItemService = $user->GetService('LineItemService', 'v201201');
// Calculate time from thirty days ago.
$thirtyDaysAgo = date(DateTimeUtils::$DFP_DATE_TIME_STRING_FORMAT,
strtotime('-30 day'));
// Create bind variables.
$vars = MapUtils::GetMapEntries(array(
'thirtyDaysAgo' => new TextValue($thirtyDaysAgo)));
// Create statement object to only select line items that
// have been modified in the last 30 days.
$filterStatement = new Statement(
"WHERE lastModifiedDateTime >= :thirtyDaysAgo "
. "LIMIT 500", $vars);
// Get line items by statement.
$page = $lineItemService->getLineItemsByStatement($filterStatement);
You will notice that we utilized a constant, DFP_DATE_TIME_STRING_FORMAT ('Y-m-d\TH:i:s'), from the library to easily format the date/time string. Also, keep in mind that the date and time specified should be in terms of the time zone that is configured for the network and any timezone specified in the string will be ignored by the server.
We hope you'll use this new feature to help save bandwidth and processing time. You can check out a full working example in
PHP or other languages in our
client libraries.
Feel free to leave us a comment on the
forum with any feedback you have for the API or topics you would like to see in the discover series.
- Paul Rashidi, DFP API Team