update adunit

12 views
Skip to first unread message

sorry chou

unread,
Mar 4, 2013, 11:15:39 PM3/4/13
to adsen...@googlegroups.com
php client libraries example introduce how to update adunit using patch method, but it will fail when change contentAdsSettings. backupOption.type

if you want change url to blank, always get error message "url must be blank", but you can't not slove this problem even reassign contentAdsSettings. backupOption.url = ""

we can using update method as follows

1. get old adunit 
    $old_adunit = $adSenseHost->accounts_adunits->get($accountid, $clientid, $adunitid);
2. create new adunit object
    $adUnit = new Google_AdUnit();

3. assign
    $adUnit->setName($old_adunit['name']);
    $adUnit->setId($old_adunit['id']);
    $adUnit->setCode($old_adunit['code']);
    $adUnit->setKind($old_adunit['kind']);
    $adUnit->setStatus($old_adunit['status']);
    and other parameters

4 $result=$adSenseHost->accounts_adunits->update($accountid, $clientid, $adUnit);

update complete :)

 
Reply all
Reply to author
Forward
0 new messages