public function testSubaccountDoesntExist()
 {
     $creds = Credentials::get();
     $client = new GSC_Client($creds["merchantId"]);
     $client->login($creds["email"], $creds["password"]);
     $errors = $client->getAccount("1");
     $errors = $errors->getErrors();
     $error = $errors[0];
     $this->assertEquals('ResourceNotFoundException', $error->getCode());
 }
예제 #2
0
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @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
$id = "SKU124";
$country = "US";
$language = "en";
$product = buildMockProduct($id, $country, $language);
// Finally send the data to the API
$entry = $client->insertProduct($product);
echo 'Inserted: ' . $entry->getTitle() . "\n";
// Get the product you just created
$retrievedProduct = $client->getProduct($id, $country, $language);
echo 'Retrieved: ' . $retrievedProduct->getTitle() . "\n";
/**
 * Credentials - Enter your own values
 *
예제 #3
0
 *   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @version 1.3
 * @author dhermes@google.com
 * @copyright Google Inc, 2011
 * @package GShoppingContent
 */
// 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"]);
// Get all products
$allProducts = $client->getProducts();
echo 'Total Number of Products: ' . count($allProducts->getProducts()) . "\n";
// Get list containing first product
$maxResults = "1";
$feed = $client->getProducts($maxResults);
$products = $feed->getProducts();
$product = $products[0];
echo 'First Product: ' . $product->getTitle() . "\n";
// Get list containing second product (and so on, paging through results)
$nextStartToken = $feed->getStartToken();
$nextFeed = $client->getProducts($maxResults, $nextStartToken);
$products = $nextFeed->getProducts();
$product = $products[0];
 *   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @version 1.3
 * @author afshar@google.com
 * @copyright Google Inc, 2011
 * @package GShoppingContent
 */
// 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();
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @version 1.3
 * @author afshar@google.com, 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"]);
// 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();
예제 #6
0
 *   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @version 1.3
 * @author dhermes@google.com
 * @copyright Google Inc, 2011
 * @package GShoppingContent
 */
// 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"]);
$accountId = "123456";
$account = $client->getAccount($accountId);
echo 'Retrieved: ' . $account->getTitle() . "\n";
/**
 * Credentials - Enter your own values
 *
 * @author afshar@google.com
**/
class Credentials
{
    public static function get()
    {
        return array("merchantId" => "7842698", "email" => "*****@*****.**", "password" => "subhanul");
    }
예제 #7
0
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @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
$id = "SKU124";
$country = "US";
$language = "en";
$product = buildMockProduct($id, $country, $language);
// Finally send the data to the API
$entry = $client->insertProduct($product);
echo 'Inserted: ' . $entry->getTitle() . "\n";
// Delete the product
$client->deleteProduct($entry);
echo "Delete succeeded\n";
// Verify the product is deleted
$errors = $client->getProduct($id, $country, $language);
echo 'Response Tag after Delete: ' . $errors->model->tagName . "\n";
예제 #8
0
 *   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @version 1.3
 * @author dhermes@google.com
 * @copyright Google Inc, 2011
 * @package GShoppingContent
 */
// 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"]);
// Get all accounts
$feed = $client->getDatafeeds();
echo 'Total Number of Datafeeds: ' . $feed->getTotalResults() . "\n";
$datafeeds = $feed->getDatafeeds();
foreach ($datafeeds as $index => $datafeed) {
    echo 'Datafeed ' . $index . ': ' . $datafeed->getEditLink() . "\n";
}
/**
 * Credentials - Enter your own values
 *
 * @author afshar@google.com
**/
class Credentials
{
예제 #9
0
 *   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @version 1.3
 * @author afshar@google.com, dhermes@google.com
 * @copyright Google Inc, 2011
 * @package GShoppingContent
 */
// 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");
// Finally send the data to the API
$entry = $client->insertProduct($product);
echo 'Inserted: ' . $entry->getTitle() . "\n";
/**
 * Credentials - Enter your own values
 *
예제 #10
0
 *   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @version 1.3
 * @author dhermes@google.com
 * @copyright Google Inc, 2011
 * @package GShoppingContent
 */
// 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 datafeed data
$datafeed = new GSC_Datafeed();
$datafeed->setTitle("ABC Store Electronics products feed");
$datafeed->setFeedFileName("electronics.txt");
$datafeed->setTargetCountry("US");
$datafeed->setContentLanguage("en");
$datafeed->setAttributeLanguage("en");
$datafeed->setFileFormat("dsv");
$datafeed->setDelimiter("pipe");
$datafeed->setEncoding("utf8");
$datafeed->setUseQuotedFields("no");
$insertedDatafeed = $client->insertDatafeed($datafeed);
echo 'Inserted: ' . $insertedDatafeed->getTitle() . "\n";
/**
예제 #11
0
 *   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @version 1.3
 * @author dhermes@google.com
 * @copyright Google Inc, 2011
 * @package GShoppingContent
 */
// 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 account data
$account = new GSC_ManagedAccount();
$account->setTitle("ABC Store");
$account->setDescription("Description of ABC Store");
$account->setAccountLink("http://abcstore.example.com/new");
$account->setAdultContent("no");
$account->setInternalId("BCDE");
$account->setReviewsUrl("http://my.site.com/reviews?mo=user-rating");
$insertedAccount = $client->insertAccount($account);
$atomId = $insertedAccount->getAtomId();
echo 'Inserted: ' . $atomId . "\n";
// Now delete the element
$client->deleteAccount($insertedAccount);
echo "Delete succeeded\n";
예제 #12
0
 *   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @version 1.3
 * @author dhermes@google.com
 * @copyright Google Inc, 2011
 * @package GShoppingContent
 */
// 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"]);
// Get all accounts
$allAccounts = $client->getAccounts();
echo 'Total Number of Accounts: ' . count($allAccounts->getAccounts()) . "\n";
// Get list containing first account
$maxResults = "1";
$feed = $client->getAccounts($maxResults);
echo 'Total Results: ' . $feed->getTotalResults() . "\n";
$accounts = $feed->getAccounts();
$account = $accounts[0];
echo 'First Account: ' . $account->getTitle() . "\n";
// Get list containing second account (and so on, paging through results)
$maxResults = "1";
$startIndex = "2";
$nextFeed = $client->getAccounts($maxResults, $startIndex);
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @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"]);
// Insert a product so we can update it in a batch request
$product = buildMockProduct("SKU123", "US", "en");
$product = $client->insertProduct($product);
echo 'Inserted: ' . $product->getTitle() . "\n";
// Update the price and add updated product to batch
$product->setPrice("20", "usd");
$product->setBatchOperation("update");
$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 'Updated: ' . $operation->getTitle() . "\n";
예제 #14
0
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @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";
예제 #15
0
 * @package GShoppingContent
 */
// import our library
require_once 'GShoppingContent.php';
// Your merchant center account id.
const ACCOUNT_ID = '1234567';
// CLIENT_ID, CLIENT_SECRET, APPLICATION_REDIRECT_URL are avaible on
// Google APIs Console (https://code.google.com/apis/console/)
const CLIENT_ID = 'YOUR CLIENT ID';
const CLIENT_SECRET = 'YOUR CLIENT SECRET';
const APPLICATION_REDIRECT_URI = 'YOUR REDIRECT URI';
const USER_AGENT = 'content-api-example';
$authToken = new GSC_OAuth2Token(CLIENT_ID, CLIENT_SECRET, APPLICATION_REDIRECT_URI, USER_AGENT);
// generate a consent page url
$authorizeUrl = $authToken->generateAuthorizeUrl(APPLICATION_REDIRECT_URI, 'force');
echo "Please visit: {$authorizeUrl}\n";
// Your browser will be redirected to
// http://your_redirection_url/?code=[CODE]
// Copy the code and enter it after the prompt.
// read the code from console
$code = readline('Please enter the code: ');
$authToken->getAccessToken($code);
// Create a client for our merchant and log in
$client = new GSC_Client(ACCOUNT_ID);
$client->setToken($authToken);
// retrieve all product items
$productFeed = $client->getProducts();
$products = $productFeed->getProducts();
foreach ($products as $product) {
    echo $product->getTitle() . "\n";
}
예제 #16
0
 *   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @version 1.3
 * @author dhermes@google.com
 * @copyright Google Inc, 2011
 * @package GShoppingContent
 */
// 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 account data
$account = new GSC_ManagedAccount();
$account->setTitle("ABC Store");
$account->setDescription("Description of ABC Store");
$account->setAccountLink("http://abcstore.example.com/new");
$account->setAdultContent("no");
$account->setInternalId("BCDE");
$account->setReviewsUrl("http://my.site.com/reviews?mo=user-rating");
$insertedAccount = $client->insertAccount($account);
echo 'Inserted: ' . $insertedAccount->getAtomId() . "\n";
/**
 * Credentials - Enter your own values
 *
 * @author afshar@google.com
예제 #17
0
 *   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @version 1.3
 * @author dhermes@google.com
 * @copyright Google Inc, 2011
 * @package GShoppingContent
 */
// 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"]);
$datafeedId = "123456";
$datafeed = $client->getDatafeed($datafeedId);
echo 'Retrieved: ' . $datafeed->getTitle() . "\n";
/**
 * Credentials - Enter your own values
 *
 * @author afshar@google.com
**/
class Credentials
{
    public static function get()
    {
        return array("merchantId" => "7842698", "email" => "*****@*****.**", "password" => "subhanul");
    }
예제 #18
0
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @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
$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";
/**
예제 #19
0
 *   distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *   WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 *   License for the specific language governing permissions and limitations
 *   under the License.
 *
 * @version 1.3
 * @author dhermes@google.com
 * @copyright Google Inc, 2011
 * @package GShoppingContent
 */
// 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 datafeed data
$datafeed = new GSC_Datafeed();
$datafeed->setTitle("ABC Store Electronics products feed");
$datafeed->setFeedFileName("electronics.txt");
$datafeed->setTargetCountry("US");
$datafeed->setContentLanguage("en");
$datafeed->setAttributeLanguage("en");
$datafeed->setFileFormat("dsv");
$datafeed->setDelimiter("pipe");
$datafeed->setEncoding("utf8");
$datafeed->setUseQuotedFields("no");
$insertedDatafeed = $client->insertDatafeed($datafeed);
$editLink = $insertedDatafeed->getEditLink();
echo 'Inserted: ' . $editLink . "\n";