/php/examples/v1_16/CreateContentCategory.php
PHP | 72 lines | 24 code | 8 blank | 40 comment | 0 complexity | 85e0d8f57ccee0f24cacd0befa05916e MD5 | raw file
- <?php
- /**
- * This example creates a content category.
- *
- * Tags: contentcategory.saveContentCategory
- *
- * PHP version 5
- * PHP extensions: SoapClient.
- *
- * Copyright 2011, Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * 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.
- *
- * @package GoogleApiAdsDfa
- * @subpackage v1_16
- * @category WebServices
- * @copyright 2011, Google Inc. All Rights Reserved.
- * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
- * Version 2.0
- * @author Joseph DiLallo <api.jdilallo@gmail.com>
- */
- require_once 'DfaHeadersUtil.php';
- // Provide information required for DFA headers.
- $username = 'INSERT_USERNAME_HERE';
- $authToken = 'INSERT_AUTHENTICATION_TOKEN_HERE';
- $applicationName = 'INSERT_APPLICATION_NAME_HERE';
- // Set SOAP and XML settings. To send requests to the production environment,
- // replace "advertisersapitest.doubleclick.net" with
- // "advertisersapi.doubleclick.net" in the wsdl URL. The namespace will always
- // be "www.doubleclick.net", even in the test environment.
- $contentCategoryWsdl = 'https://advertisersapitest.doubleclick.net/v1.16/api/' .
- 'dfa-api/contentcategory?wsdl';
- $namespace = 'http://www.doubleclick.net/dfa-api/v1.16';
- $options = array('encoding' => 'utf-8');
- // Get ContentCategoryService.
- $contentCategoryService = new SoapClient($contentCategoryWsdl, $options);
- // Set headers.
- $headers = array(DfaHeadersUtil::createWsseHeader($username, $authToken),
- DfaHeadersUtil::createRequestHeader($namespace, $applicationName));
- $contentCategoryService->__setSoapHeaders($headers);
- // Create content category structure.
- $contentCategory = array(
- 'id' => 0,
- 'name' => 'Content Category ' . uniqid(),
- 'description' => 'Created from the API.');
- try {
- // Save the content category.
- $result = $contentCategoryService->saveContentCategory($contentCategory);
- } catch (Exception $e) {
- print $e->getMessage();
- exit(1);
- }
- // Display the ID of the newly created content category.
- print "Content category with ID \"" . $result->id . "\" was created.";