// import our library require_once 'GShoppingContent.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 = new GSC_Product(); $product->setSKU("dd192"); $product->setProductLink("http://code.google.com/"); $product->setTitle("Dijji Digital Camera"); $product->setPrice("199.99", "usd"); $product->setAdult("false"); $product->setCondition("new"); $product->setBatchOperation("insert"); $batch = new GSC_ProductList(); $batch->addEntry($product); // Finally send the data to the API $feed = $client->batch($batch); $products = $feed->getProducts(); $operation = $products[0]; echo 'Inserted: ' . $operation->getTitle() . "\n"; echo 'Status: ' . $operation->getBatchStatus() . "\n"; /** * Credentials - Enter your own values * * @author afshar@google.com **/ class Credentials {
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"]); // Insert a product so we can delete it $id = "SKU124"; $country = "US"; $language = "en"; $product = buildMockProduct($id, $country, $language); $product = $client->insertProduct($product); echo 'Inserted: ' . $product->getTitle() . "\n"; // Create a dummy <atom:entry> element to include as a batch delete $dummyDeleteEntry = new GSC_Product(); $dummyDeleteEntry->setBatchOperation("delete"); // set the atom id element as specified by the batch protocol $editLink = $client->getProductUri($id, $country, $language); $dummyDeleteEntry->setAtomId($editLink); $batch = new GSC_ProductList(); $batch->addEntry($dummyDeleteEntry); // Finally send the data to the API $feed = $client->batch($batch); $products = $feed->getProducts(); $operation = $products[0]; echo 'Deleted: ' . $operation->getTitle() . "\n"; echo 'Status: ' . $operation->getBatchStatus() . "\n"; /** * Credentials - Enter your own values * * @author afshar@google.com