Publishing destinations via script

thugsb's Avatar

thugsb

03 Aug, 2015 08:42 PM

It looks like the formatting for publishing pages has changed in the web services recently? It used to be that you set 'destination' => 'name-of-destination', but now it looks like you set an array of 'destinations' (plural) with identifiers, correct?

I'm making a script that will publish multiple pages on different sites. I'm using the following:

$publish = $client->publish ( array (
  'authentication' => $auth, 
  'publishInformation' => array(
    'identifier' => array( 
      'type' => 'page', 
      'id' => $asset["id"] ), 
    'destinations' => array(
      'type' => 'destination', 
      'path' => array( 
        'path' => 'name-of-destination', 
        'siteId' => $asset["siteId"] ) ), 
    'unpublish' => false ) 
  ) 
);

However, this is still publishing to all destinations. I want it to only publish to the one I specify. How do I make that happen?

I've tried putting 'name-of-destination' as '/name-of-destination' (with a slash) too. Thanks for the help.

  1. 1 Posted by Wing Ming Chan on 04 Aug, 2015 12:15 AM

    Wing Ming Chan's Avatar

    Hi,

    The destinations property should point to an array of stdClass (identifier) objects, or to an array of arrays (containing type and path), not to a simple array.

    <complexType name="destination-list">
      <sequence>
        <element maxOccurs="unbounded" minOccurs="0" name="destination" type="impl:identifier"/>
      </sequence>
    </complexType>
    

    Wing

  2. 2 Posted by thugsb on 04 Aug, 2015 02:58 PM

    thugsb's Avatar

    Can you show me what that would look like for the PHP code above please?

  3. 3 Posted by Wing Ming Chan on 04 Aug, 2015 03:02 PM

    Wing Ming Chan's Avatar

    I don't work with raw code any more. Therefore, I have not tested the code. But try the following:

    $publish = $client->publish ( array (
      'authentication' => $auth, 
      'publishInformation' => array(
        'identifier' => array( 
          'type' => 'page', 
          'id' => $asset["id"] ), 
        'destinations' => array(
          array(
            'type' => 'destination', 
            'path' => array( 
              'path' => 'name-of-destination', 
              'siteId' => $asset["siteId"] ) ) ), 
        'unpublish' => false ) 
      ) 
    );
    

    In case you have not looked at my library, you might want to check it out.

    Wing

  4. 4 Posted by thugsb on 04 Aug, 2015 03:08 PM

    thugsb's Avatar

    That works, thanks!

  5. thugsb closed this discussion on 04 Aug, 2015 03:08 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac