* @copyright Google Inc, 2011 * @package GShoppingContent */ // import our library require_once 'GShoppingContent.php'; require_once 'BuildMockProduct.php'; // Get the user credentials $creds = Credentials::get(); // Create a client for our merchant and log in $client = new GSC_Client($creds["merchantId"]); $client->login($creds["email"], $creds["password"]); // Now enter some product data $id = "SKU124"; $country = "US"; $language = "en"; $product = buildMockProduct($id, $country, $language); // Finally send the data to the API $warnings = false; $dryRun = true; $entry = $client->insertProduct($product, $warnings, $dryRun); echo 'Dry Run Insert Response: ' . $entry->getTitle() . "\n\n"; // Verify the product still doesn't exist $errors = $client->getProduct($id, $country, $language); echo 'Response Tag after Dry Run Insert: ' . $errors->model->tagName . "\n"; /** * Credentials - Enter your own values * * @author afshar@google.com **/ class Credentials {
* * @version 1.3 * @author dhermes@google.com * @copyright Google Inc, 2011 * @package GShoppingContent */ // import our library require_once 'GShoppingContent.php'; require_once 'BuildMockProduct.php'; // Get the user credentials $creds = Credentials::get(); // Create a client for our merchant and log in $client = new GSC_Client($creds["merchantId"]); $client->login($creds["email"], $creds["password"]); // Now enter some product data $product = buildMockProduct("SKU124", "US", "en"); // Finally send the data to the API $warnings = true; $dryRun = false; $entry = $client->insertProduct($product, $warnings, $dryRun); echo 'Inserted: ' . $entry->getTitle() . "\n\n"; $warnings = $entry->getWarnings(); // A DOMNodeList $count = $warnings->length; for ($pos = 0; $pos < $count; $pos++) { $warning = $warnings->item($pos); echo 'Warning ' . ($pos + 1) . "\n"; echo 'Code: ' . $entry->getWarningCode($warning) . "\n"; echo 'Domain: ' . $entry->getWarningDomain($warning) . "\n"; echo 'Location: ' . $entry->getWarningLocation($warning) . "\n"; echo 'Message: ' . $entry->getWarningMessage($warning) . "\n\n";