Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

marketing cloud how to send sms

Posted at

0.setup--->InstalledPackages--->new

  1. api request code
       String clientId = 'clientId';
       String clientSecret = 'clientSecret';
       String tokenUrl = 'https://[get this from step 0].auth.marketingcloudapis.com/v2/token';
       
       HttpRequest req = new HttpRequest();
       req.setEndpoint(tokenUrl);
       req.setMethod('POST');
       req.setHeader('Content-Type', 'application/json');
       
       String body = '{"grant_type":"client_credentials","client_id":"' + clientId + '","client_secret":"' + clientSecret + '"}';
       req.setBody(body);
       
       Http http = new Http();
       HttpResponse res = http.send(req);
       

           Map<String, Object> responseMap = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());



Object accessToken =responseMap.get('access_token');
system.debug(accessToken);
// リクエストJSON
       String smsReqJson = '{"ContactKey": "[step 3]",'
                         + '"EventDefinitionKey":"get it from journey builder",'
                         + '"Data": {'
                         + '         "contactkey":"required",'
                         + '         "sentdate":"' + String.ValueofGmt(Datetime.now()) + '",'
                         + '         "country":"JP",'
                         + '         "phone":"yourphone",'
                         + '         "name":"yourname"'
                         + '}}';  

       // エンドポイント
       String endpoint2 = 'https://[get this from step 0].rest.marketingcloudapis.com/interaction/v1/events';
       // HTTPリクエスト
       HttpRequest req2 = new HttpRequest();
       req2.setEndpoint(endpoint2);
       req2.setMethod('POST');
       req2.setHeader('Content-Type', 'application/json');
       req2.setHeader('Authorization', 'Bearer ' + String.valueof(accessToken));
       req2.setBody(smsReqJson);


Http http2 = new Http();
       HttpResponse res2 = http2.send(req2);
       
       System.debug(res.getBody());

2.journey builder
api event---> SMS

3.mobile connect
add contacts--->manually or input file

ensure your phone number is correct and your contact key is equal to your api request code

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?