public function addPermission($topicArn, $label, $permissions = array()) {
		if(empty($topicArn) || empty($label)) {
			throw new InvalidArgumentException('Must supply TopicARN and a Label for this permission');
		}

		// Add standard params as normal
		$params = array(
			'TopicArn' => $topicArn,
			'Label' => $label
		);

		// Compile permissions into separate sequential arrays
		$memberFlatArray = array();
		$permissionFlatArray = array();

		foreach($permissions as $member => $permission) {
			if(is_array($permission)) {
				// Array of permissions
				foreach($permission as $singlePermission) {
					$memberFlatArray[] = $member;
					$permissionFlatArray[] = $singlePermission;
				}
			}
			else {
				// Just a single permission
				$memberFlatArray[] = $member;
				$permissionFlatArray[] = $permission;
			}
		}

		// Dummy check
		if(count($memberFlatArray) !== count($permissionFlatArray)) {
			// Something went wrong
			throw new InvalidArgumentException('Mismatch of permissions to users');
		}

		// Finally add to params
		for($x = 1; $x <= count($memberFlatArray); $x++) {
			$params['ActionName.member.' . $x] = $permissionFlatArray[$x];
			$params['AWSAccountID.member.' . $x] = $memberFlatArray[$x];
		}

		// Finally send request
		$this->_request('AddPermission', $params);

		return true;
	}
public function addPermission($topicArn, $label, $permissions = array()) {
		if(empty($topicArn) || empty($label)) {
			throw new InvalidArgumentException('Must supply TopicARN and a Label for this permission');
		}

		// Add standard params as normal
		$params = array(
			'TopicArn' => $topicArn,
			'Label' => $label
		);

		// Compile permissions into separate sequential arrays
		$memberFlatArray = array();
		$permissionFlatArray = array();

		foreach($permissions as $member => $permission) {
			if(is_array($permission)) {
				// Array of permissions
				foreach($permission as $singlePermission) {
					$memberFlatArray[] = $member;
					$permissionFlatArray[] = $singlePermission;
				}
			}
			else {
				// Just a single permission
				$memberFlatArray[] = $member;
				$permissionFlatArray[] = $permission;
			}
		}

		// Dummy check
		if(count($memberFlatArray) !== count($permissionFlatArray)) {
			// Something went wrong
			throw new InvalidArgumentException('Mismatch of permissions to users');
		}

		// Finally add to params
		for($x = 1; $x <= count($memberFlatArray); $x++) {
			$params['ActionName.member.' . $x] = $permissionFlatArray[$x];
			$params['AWSAccountID.member.' . $x] = $memberFlatArray[$x];
		}

		// Finally send request
		$this->_request('AddPermission', $params);

		return true;
	}
public function addPermission ( $ topicArn , $ label , $ permissions = array ( ) ) { if ( empty ( $ topicArn ) || empty ( $ label ) ) { throw new InvalidArgumentException ( 'Must supply TopicARN and a Label for this permission' ) ; } // Add standard params as normal $ params = array ( 'TopicArn' => $ topicArn , 'Label' => $ label ) ; // Compile permissions into separate sequential arrays $ memberFlatArray = array ( ) ; $ permissionFlatArray = array ( ) ; foreach ( $ permissions as $ member => $ permission ) { if ( is_array ( $ permission ) ) { // Array of permissions foreach ( $ permission as $ singlePermission ) { $ memberFlatArray [ ] = $ member ; $ permissionFlatArray [ ] = $ singlePermission ; } } else { // Just a single permission $ memberFlatArray [ ] = $ member ; $ permissionFlatArray [ ] = $ permission ; } } // Dummy check if ( count ( $ memberFlatArray ) !== count ( $ permissionFlatArray ) ) { // Something went wrong throw new InvalidArgumentException ( 'Mismatch of permissions to users' ) ; } // Finally add to params for ( $ x = 1 ; $ x <= count ( $ memberFlatArray ) ; $ x ++ ) { $ params [ 'ActionName.member.' . $ x ] = $ permissionFlatArray [ $ x ] ; $ params [ 'AWSAccountID.member.' . $ x ] = $ memberFlatArray [ $ x ] ; } // Finally send request $ this -> _request ( 'AddPermission' , $ params ) ; return true ; }
Add permissions to a topic

Example:
$AmazonSNS->addPermission('topic:arn:123', 'New Permission', array('987654321000' => 'Publish', '876543210000' => array('Publish', 'SetTopicAttributes')));

@link http://docs.amazonwebservices.com/sns/latest/api/API_AddPermission.html
@param string $topicArn
@param string $label Unique name of permissions
@param array $permissions [optional] Array of permissions - member ID as keys, actions as values
@return bool
@throws InvalidArgumentException
Add permissions to a topic