private function createExampleAccount($name) { $account = new Google_Service_ShoppingContent_Account(); $account->setName($name); $account->setWebsiteUrl('https://' . $name . '.example.com/'); return $account; }
public function unlinkAdWordsAccount(Google_Service_ShoppingContent_Account $account, $adwords_id) { $adwords_links = array(); $found = false; foreach ($account->getAdwordsLinks() as $adwords_link) { if ($adwords_link->getAdwordsId() == $adwords_id) { $found = true; } else { $adwords_links[] = $adwords_link; } } // Don't send an update request if the link we are trying to // remove was not found on the account. if ($found) { $account->setAdwordsLinks($adwords_links); try { $response = $this->service->accounts->update($this->merchant_id, $this->merchant_id, $account); printf("Unlinked AdWords account '%s' from account\n", $adwords_id); } catch (Google_Service_Exception $exception) { print "There were errors while trying to unlink an account:\n"; foreach ($exception->getErrors() as $error) { printf("* %s\n", $error["message"]); } } } }