Ejemplo n.º 1
0
 */
// $tag->site_id = $site->id;
$tag = $tagService->insert($tag);
echo 'your new inserted tag:' . PHP_EOL;
print_r($tag);
/**
 * once you added a tag, sites may get also referenced by it,
 * you can now use a tag object as alternative for the id:
 *
 * note: keys and values are only allowed to contain a-z and 0-9 as characters
 */
$tag = new \Productsup\Platform\Tag();
$tag->key = 'myidentifier';
$tag->value = '321';
$sitesService = new \Productsup\Service\Sites($Client);
$sites = $sitesService->get($tag);
echo 'result for getting a site via its tag:' . PHP_EOL;
print_r($sites);
/**
 * if you do have a site_id and want to know which tags are assigned to it, you can query for them like this:
 */
$tagService = new \Productsup\Service\Tags($Client);
$tagService->setSite($sites[0]);
$tags = $tagService->get();
echo 'tags assigned to the test-site:' . PHP_EOL;
print_r($tags);
/**
 * if you want to change an existing tag, you can simply update it:
 */
$tagService = new \Productsup\Service\Tags($Client);
$tags[0]->value = '123';
Ejemplo n.º 2
0
 **/
$Client = new Productsup\Client();
$Client->id = 1234;
$Client->secret = 'simsalabim';
/**
 * Initialize the Sites Service where you can
 *
 * Create a new site (Sites->insert())
 * Delete a site (Sites->delete())
 * Get a list of sites (Sites->get())
 */
$Sites = new Productsup\Service\Sites($Client);
/**
 * getting all sites:
 */
$SiteList = $Sites->get();
echo 'Get all your sites: ' . PHP_EOL;
foreach ($SiteList as $siteObj) {
    echo $siteObj->id . ' ' . $siteObj->title . PHP_EOL;
}
/**
 * to get a certain site you may pass a reference,
 * how references are created is explained later
 */
$reference = new \Productsup\Platform\Site\Reference();
$reference->setKey('MyTestReference');
$reference->setValue('1234');
$SiteList = $Sites->get($reference);
echo 'Get one site by its id: ' . PHP_EOL;
print_r($SiteList);
echo 'Getting a site that does not exist results in an ClientException: ' . PHP_EOL;