This quick guide aims to help you start with Infobip Moments API.
Initialize configuration:
$configuration = new Configuration(
host: 'your-base-url',
apiKey: 'your-api-key'
);
You can now create an instance of FlowApi
which allows you to manage your flows.
$flowApi = new FlowApi(config: $configuration);
To add participants to a flow, you can use the following code:
$campaignId = '200000000000001';
$request = new FlowAddFlowParticipantsRequest(
participants: [
new FlowParticipant(
identifyBy: new FlowPersonUniqueField(
identifier: '[email protected]',
type: FlowPersonUniqueFieldType::EMAIL
),
variables: ['orderNumber' => 1167873391]
)
],
notifyUrl: 'https://example.com/callback',
);
$status = $flowApi->addFlowParticipants($campaignId, $request);
The received status will contain the operation ID that you can use to track the status of the operation.
To fetch a report to confirm that all persons have been successfully added to the flow, you can use the following code:
$report = $flowApi->getFlowParticipantsAddedReport($campaignId, $status->getOperationId());
To remove a person from a flow, you can use the following code:
$externalId = '8edb24b5-0319-48cd-a1d9-1e8bc5d577ab';
$flowApi->removePeopleFromFlow($campaignId, null, null, $externalId);
You can now create an instance of FormsApi
which allows you to manage your forms.
$formsApi formsApi = new FormsApi(config: $configuration);
To get all your forms, you can use the following code:
$formsResponse = $formsApi->getForms();
To get a specific form by its ID, you can use the following code:
$formId = 'cec5dfd2-4238-48e0-933b-9acbdb2e6f5f';
$formResponse = $formsApi->getForm($formId);
To increase the view counter of a specific form, you can use the following code:
$status = $formsApi->incrementViewCount($formId);
To submit data to a specific form, you can use the following code:
$data = [
'first_name' => 'John',
'last_name' => 'Doe',
'company' => 'Infobip',
'email' => '[email protected]'
];
$status = $formsApi->submitFormData($formId, $data);