Search code examples
phpamazon-web-servicesamazon-snsaws-php-sdk

Where in the AWS API can I set the sender id for sending SMS


I am trying to set the sender ID in my API call, but it is being ignored. Where do I put it/what is the correct attribute name? I am in the USA, Below are the two places I tried to set the sender id (I tried both SenderID and DefaultSenderID)

    $result = $SnSclient->SetSMSAttributes([
        'attributes' => [
            'DefaultSMSType' => 'Transactional',
            'AWS.SNS.SMS.SenderID' =>'CompanyBrand'

        ],
    ]);
    var_dump($result);//this currently gives an error (method call, not the var_dump)

    $result = $SnSclient->publish([
        'Message' => $message,
        'PhoneNumber' => $phone,
        'SenderID' => 'CompanyBrand'
    ]);

Solution

  • I realise that you use PHP, but I'm a Python person. Just for comparison, this code worked for me:

    import boto3
    
    sns_client = boto3.client('sns')
    
    response = sns_client.set_sms_attributes(
        attributes={
            'DefaultSenderID': 'Foo'
        }
    )
    print(response)
    
    sns_client.publish(Message='Hello',PhoneNumber='+xxx')
    

    I noticed that it didn't like having a Space in the DefaultSenderID.

    SenderID is not a valid parameter in the publish() command. Nor does it seem to recognize it as a MessageAttribute within the publish() command.