Skip to content

Commit 375c861

Browse files
committed
Add simple examples
1 parent fefdd3e commit 375c861

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

example/example.php

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
// new Api("...", "...", false, true) to enable debug output
3+
$sendgrid = new SendGrid\Api("my_username", "my_password");
4+
5+
// Initialize new user without actually creating it
6+
$user = new SendGrid\SubUser("wanted_username", "password", "email@example.com",
7+
"email.domain.example.com"); // Many optional arguments available
8+
9+
// Add the sub user to your account
10+
$sendgrid->addSubUser($user);
11+
12+
// Assign an IP to the user
13+
$user->assignIps(array("1.2.3.4"));
14+
15+
// Enable and configure an app
16+
$user->enableApp("eventnotify", true, array(
17+
'processed' => false,
18+
'dropped' => true,
19+
'deferred' => false,
20+
'delivered' => false,
21+
'bounce' => true,
22+
'click' => false,
23+
'open' => false,
24+
'unsubscribe' => false,
25+
'spamreport' => true,
26+
'url' => 'http://example.com/url-to-event-receiver'));
27+
28+
// Instead of creating a user, we can retrieve one
29+
$user = $sendgrid->getSubUser("another_sub_username");
30+
31+
// Get a list of available apps for the user
32+
$apps = $user->getApps();
33+
34+
// Get current settings for a specific app
35+
$settings = $user->getAppSettings("eventnotify");

0 commit comments

Comments
 (0)