Esempi di API Amazon Pinpoint SMS e Voice con SDK per SAP ABAP - AWS Esempi di codice SDK

Sono disponibili altri esempi AWS SDK nel repository AWS Doc SDK Examples. GitHub

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Esempi di API Amazon Pinpoint SMS e Voice con SDK per SAP ABAP

I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando l' AWS SDK per SAP ABAP con l'API Amazon Pinpoint SMS and Voice.

Le azioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le azioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.

Ogni esempio include un link al codice sorgente completo, in cui vengono fornite le istruzioni su come configurare ed eseguire il codice nel contesto.

Argomenti

Azioni

Il seguente esempio di codice mostra come usare. CreateConfigurationSet

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. " Create a new configuration set lo_pps->createconfigurationset( iv_configurationsetname = iv_configuration_set_name " e.g., 'my-config-set' ). MESSAGE 'Configuration set created successfully.' TYPE 'I'. CATCH /aws1/cx_ppsalreadyexistsex INTO DATA(lo_already_exists_ex). MESSAGE lo_already_exists_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_already_exists_ex. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppslimitexceededex INTO DATA(lo_limit_exceeded_ex). MESSAGE lo_limit_exceeded_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_limit_exceeded_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.

Il seguente esempio di codice mostra come utilizzare. CreateConfigurationSetEventDestination

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. " Create event destination for the configuration set lo_pps->createconfseteventdst( iv_configurationsetname = iv_configuration_set_name " e.g., 'my-config-set' iv_eventdestinationname = iv_event_destination_name " e.g., 'my-event-dest' io_eventdestination = io_event_destination ). MESSAGE 'Event destination created successfully.' TYPE 'I'. CATCH /aws1/cx_ppsalreadyexistsex INTO DATA(lo_already_exists_ex). MESSAGE lo_already_exists_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_already_exists_ex. CATCH /aws1/cx_ppsnotfoundexception INTO DATA(lo_not_found_ex). MESSAGE lo_not_found_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found_ex. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppslimitexceededex INTO DATA(lo_limit_exceeded_ex). MESSAGE lo_limit_exceeded_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_limit_exceeded_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.

Il seguente esempio di codice mostra come utilizzare. DeleteConfigurationSet

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. " Delete the configuration set lo_pps->deleteconfigurationset( iv_configurationsetname = iv_configuration_set_name " e.g., 'my-config-set' ). MESSAGE 'Configuration set deleted successfully.' TYPE 'I'. CATCH /aws1/cx_ppsnotfoundexception INTO DATA(lo_not_found_ex). MESSAGE lo_not_found_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found_ex. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.

Il seguente esempio di codice mostra come utilizzare. DeleteConfigurationSetEventDestination

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. " Delete the event destination lo_pps->deleteconfseteventdst( iv_configurationsetname = iv_configuration_set_name " e.g., 'my-config-set' iv_eventdestinationname = iv_event_destination_name " e.g., 'my-event-dest' ). MESSAGE 'Event destination deleted successfully.' TYPE 'I'. CATCH /aws1/cx_ppsnotfoundexception INTO DATA(lo_not_found_ex). MESSAGE lo_not_found_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found_ex. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.

Il seguente esempio di codice mostra come utilizzare. GetConfigurationSetEventDestinations

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. " Get event destinations for the configuration set oo_result = lo_pps->getconfseteventdestinations( iv_configurationsetname = iv_configuration_set_name " e.g., 'my-config-set' ). " Process the event destinations LOOP AT oo_result->get_eventdestinations( ) INTO DATA(lo_event_dest). DATA(lv_dest_name) = lo_event_dest->get_name( ). DATA(lv_enabled) = lo_event_dest->get_enabled( ). MESSAGE |Event destination: { lv_dest_name }, Enabled: { lv_enabled }| TYPE 'I'. " Check for CloudWatch Logs destination DATA(lo_cloudwatch_dest) = lo_event_dest->get_cloudwatchlogsdst( ). IF lo_cloudwatch_dest IS NOT INITIAL. DATA(lv_log_group_arn) = lo_cloudwatch_dest->get_loggrouparn( ). MESSAGE | CloudWatch Logs destination: { lv_log_group_arn }| TYPE 'I'. ENDIF. " Check for Kinesis Firehose destination DATA(lo_firehose_dest) = lo_event_dest->get_kinesisfirehosedst( ). IF lo_firehose_dest IS NOT INITIAL. DATA(lv_delivery_stream) = lo_firehose_dest->get_deliverystreamarn( ). MESSAGE | Kinesis Firehose destination: { lv_delivery_stream }| TYPE 'I'. ENDIF. " Check for SNS destination DATA(lo_sns_dest) = lo_event_dest->get_snsdestination( ). IF lo_sns_dest IS NOT INITIAL. DATA(lv_topic_arn) = lo_sns_dest->get_topicarn( ). MESSAGE | SNS destination: { lv_topic_arn }| TYPE 'I'. ENDIF. ENDLOOP. CATCH /aws1/cx_ppsnotfoundexception INTO DATA(lo_not_found_ex). MESSAGE lo_not_found_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found_ex. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.

Il seguente esempio di codice mostra come utilizzare. ListConfigurationSets

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. " List all configuration sets oo_result = lo_pps->listconfigurationsets( iv_nexttoken = iv_next_token " Optional: Token for pagination iv_pagesize = iv_page_size " Optional: Number of results per page, e.g., '10' ). " Process the configuration sets LOOP AT oo_result->get_configurationsets( ) INTO DATA(lo_config_set). DATA(lv_config_set_name) = lo_config_set->get_value( ). MESSAGE |Configuration set: { lv_config_set_name }| TYPE 'I'. ENDLOOP. " Check if there are more results DATA(lv_next_token) = oo_result->get_nexttoken( ). IF lv_next_token IS NOT INITIAL. MESSAGE |More results available. Next token: { lv_next_token }| TYPE 'I'. ENDIF. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.

Il seguente esempio di codice mostra come utilizzare. SendVoiceMessage

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. " Create SSML message type object with voice parameters DATA(lo_ssml_message) = NEW /aws1/cl_ppsssmlmessagetype( iv_languagecode = iv_language_code " e.g., 'en-US' iv_voiceid = iv_voice_id " e.g., 'Matthew' iv_text = iv_ssml_message " SSML formatted message text ). " Create voice message content with the SSML message DATA(lo_content) = NEW /aws1/cl_ppsvoicemessagecont( io_ssmlmessage = lo_ssml_message ). " Send the voice message DATA(lo_result) = lo_pps->sendvoicemessage( iv_originationphonenumber = iv_origination_number " e.g., '+12065550110' iv_callerid = iv_caller_id " e.g., '+12065550199' iv_destinationphonenumber = iv_destination_number " e.g., '+12065550142' io_content = lo_content ). " Retrieve the message ID from the response ov_message_id = lo_result->get_messageid( ). MESSAGE 'Voice message sent successfully.' TYPE 'I'. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.
  • Per i dettagli sulle API, SendVoiceMessageconsulta AWS SDK for SAP ABAP API reference.

Il seguente esempio di codice mostra come utilizzare. UpdateConfigurationSetEventDestination

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. " Update the event destination lo_pps->updateconfseteventdst( iv_configurationsetname = iv_configuration_set_name " e.g., 'my-config-set' iv_eventdestinationname = iv_event_destination_name " e.g., 'my-event-dest' io_eventdestination = io_event_destination ). MESSAGE 'Event destination updated successfully.' TYPE 'I'. CATCH /aws1/cx_ppsnotfoundexception INTO DATA(lo_not_found_ex). MESSAGE lo_not_found_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found_ex. CATCH /aws1/cx_ppsbadrequestex INTO DATA(lo_bad_request_ex). MESSAGE lo_bad_request_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request_ex. CATCH /aws1/cx_ppsinternalsvcerrorex INTO DATA(lo_internal_error_ex). MESSAGE lo_internal_error_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_internal_error_ex. CATCH /aws1/cx_ppstoomanyrequestsex INTO DATA(lo_too_many_requests_ex). MESSAGE lo_too_many_requests_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many_requests_ex. ENDTRY.