src/Provider/AwsProvider.php
public function subscribeToTopic($topicArn, $protocol, $endpoint)
    {
        // Check against the current Topic Subscriptions
        $subscriptions = $this->getTopicSubscriptions($topicArn);
        foreach ($subscriptions as $subscription) {
            if ($endpoint === $subscription['Endpoint']) {
                return $subscription['SubscriptionArn'];
            }
        }

        $result = $this->sns->subscribe([
            'TopicArn' => $topicArn,
            'Protocol' => $protocol,
            'Endpoint' => $endpoint
        ]);

        $arn = $result->get('SubscriptionArn');

        $context = [
            'Endpoint' => $endpoint,
            'Protocol' => $protocol,
            'SubscriptionArn' => $arn
        ];
        $this->log(200, "Endpoint Subscribed to SNS Topic", $context);

        return $arn;
    }
public function subscribeToTopic($topicArn, $protocol, $endpoint)
    {
        // Check against the current Topic Subscriptions
        $subscriptions = $this->getTopicSubscriptions($topicArn);
        foreach ($subscriptions as $subscription) {
            if ($endpoint === $subscription['Endpoint']) {
                return $subscription['SubscriptionArn'];
            }
        }

        $result = $this->sns->subscribe([
            'TopicArn' => $topicArn,
            'Protocol' => $protocol,
            'Endpoint' => $endpoint
        ]);

        $arn = $result->get('SubscriptionArn');

        $context = [
            'Endpoint' => $endpoint,
            'Protocol' => $protocol,
            'SubscriptionArn' => $arn
        ];
        $this->log(200, "Endpoint Subscribed to SNS Topic", $context);

        return $arn;
    }
public function subscribeToTopic ( $ topicArn , $ protocol , $ endpoint ) { // Check against the current Topic Subscriptions $ subscriptions = $ this -> getTopicSubscriptions ( $ topicArn ) ; foreach ( $ subscriptions as $ subscription ) { if ( $ endpoint === $ subscription [ 'Endpoint' ] ) { return $ subscription [ 'SubscriptionArn' ] ; } } $ result = $ this -> sns -> subscribe ( [ 'TopicArn' => $ topicArn , 'Protocol' => $ protocol , 'Endpoint' => $ endpoint ] ) ; $ arn = $ result -> get ( 'SubscriptionArn' ) ; $ context = [ 'Endpoint' => $ endpoint , 'Protocol' => $ protocol , 'SubscriptionArn' => $ arn ] ; $ this -> log ( 200 , "Endpoint Subscribed to SNS Topic" , $ context ) ; return $ arn ; }
Subscribes an endpoint to a SNS Topic

@param string $topicArn The ARN of the Topic
@param string $protocol The protocol of the Endpoint
@param string $endpoint The Endpoint of the Subscriber

@return string
Subscribes an endpoint to a SNS Topic