Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

Commit 08165f2

Browse files
author
Josh Wolff
committed
Updating README
1 parent b20d6b0 commit 08165f2

File tree

9 files changed

+95
-51
lines changed

9 files changed

+95
-51
lines changed

.idea/workspace.xml

Lines changed: 36 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ This repository is the Python wrapper for our API. To see code snippets for seve
2323
8) Run the command `help(SpontitResource)` in Python for complete documentation.
2424
9) Or try an example! Check out the <a href="https://github.com/spontit/spontit-api-python-wrapper/blob/master/spontit/examples/examples.py">examples</a>.
2525
10) You can customize the image of the notification on the website, iPhone app, or via the API by setting the image for the respective channel. See the image example titled `create_new_channel_with_profile_image_and_push_to_it` in the <a href="https://github.com/spontit/spontit-api-python-wrapper/blob/master/spontit/examples/examples.py">examples</a>.
26-
11) To push to others, have them follow the channel to which you will push (e.g. share <a href="https://spontit.com">spontit.com/my_username</a>). You can see available invite options by calling `print(resource.get_channel(...))` and supply the channel name. See the functions titled `create_new_channel_and_get_invite_options` and `get_invite_options_for_my_main_account` in the <a href="https://github.com/spontit/spontit-api-python-wrapper/blob/master/spontit/examples/examples.py">examples</a>.
27-
12) <b>Spontit is more than just broadcasting. You can send pushes to specific users and push personalized content.</b> See how to do so at `simple_push_to_specific_followers_example` and `specific_followers_and_channel_example` in the <a href="https://github.com/spontit/spontit-api-python-wrapper/blob/master/spontit/examples/examples.py">examples</a>. You simply input a list of usernames and it will push to those users (provided they follow the specified channel). You can list the usernames of those who follow one of your specified channels. See an example of how to do so at `list_followers_example` and `list_followers_for_channel_example` in the <a href="https://github.com/spontit/spontit-api-python-wrapper/blob/master/spontit/examples/examples.py">examples</a>.
26+
11) To push to others, you can do two things.<br>
27+
a) Have them sign up with a known email or phone number. Then push to them directly using their email or phone number. They do not have to follow you in order to receive the push. See `simple_push_to_specific_phone_numbers_and_emails_example` for an example (in the <a href="https://github.com/spontit/spontit-api-python-wrapper/blob/master/spontit/examples/examples.py">examples</a> file).<br>
28+
b) Have them follow the channel to which you will push (e.g. share <a href="https://spontit.com">spontit.com/my_username</a>). You can see available invite options by calling `print(resource.get_channel(...))` and supply the channel name. See the functions titled `create_new_channel_and_get_invite_options` and `get_invite_options_for_my_main_account` in the <a href="https://github.com/spontit/spontit-api-python-wrapper/blob/master/spontit/examples/examples.py">examples</a>.
29+
12) <b>Spontit is more than just broadcasting. You can send pushes to specific users and push personalized content.</b> See how to do so at `simple_push_to_specific_followers_example`, `simple_push_to_specific_phone_numbers_and_emails_example`, and `specific_followers_and_channel_example` in the <a href="https://github.com/spontit/spontit-api-python-wrapper/blob/master/spontit/examples/examples.py">examples</a>. You simply input a list of usernames and it will push to those users (provided they follow the specified channel) -- or input a list of phone numbers and emails (they do not have to follow the given channel; see part 4(a)). You can list the usernames of those who follow one of your specified channels. See an example of how to do so at `list_followers_example` and `list_followers_for_channel_example` in the <a href="https://github.com/spontit/spontit-api-python-wrapper/blob/master/spontit/examples/examples.py">examples</a>.
2830
13) We are constantly working on expanding the functionality of Spontit. We GREATLY appreciate your input - feel free to <a href="https://github.com/spontit/spontit-api-python-wrapper/issues/new" target="_blank">add a feature request</a> on our Github. :smiley:
2931

3032
### Getting Started :white_check_mark:

build/lib/spontit/examples/examples.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,30 @@ def simple_push_to_specific_followers_example(self):
3939
print(response)
4040
return response
4141

42+
def simple_push_to_specific_phone_numbers_and_emails_example(self):
43+
"""
44+
Sends a push notification to phone numbers and emails. We link the user account to the phone numbers and emails
45+
defined, and then send a push via Spontit.
46+
The users linked **do not have to follow your account** to receive the push notification.
47+
They will have the option to follow you or report you for spam. If you are reported for spam multiple times,
48+
your account will be restricted.
49+
:return:
50+
"""
51+
# TODO- Replace with a real phone number.
52+
phone_numbers = ["+18005550101"]
53+
# TODO- Replace with a real email.
54+
emails = ['fake.email@fake.com']
55+
response = self.__resource.push(
56+
"Hello to other users!",
57+
body="Add any phone numbers or emails to this push. Tell users to sign up on Spontit with the same "
58+
"phone number / email as they signed up with using your service. Then you can push directly to them.",
59+
push_to_phone_numbers=phone_numbers,
60+
push_to_emails=emails
61+
)
62+
print(f"Notification sent to:\nEmails: {str(emails)}\nPhone numbers: {str(phone_numbers)}")
63+
print(response)
64+
return response
65+
4266
def list_followers_example(self):
4367
"""
4468
Lists all your followers.
@@ -312,6 +336,7 @@ def do_everything(self):
312336
self.scheduled_push,
313337
self.immediate_expiration_push,
314338
self.simple_push_to_specific_followers_example,
339+
self.simple_push_to_specific_phone_numbers_and_emails_example,
315340
self.list_followers_example,
316341
self.list_followers_for_channel_example,
317342
self.specific_followers_and_channel_example,
@@ -342,8 +367,11 @@ def do_everything(self):
342367

343368
if __name__ == "__main__":
344369
# Try an example...
345-
spontit_src = SpontitResource("my_username", "my_secret_key")
370+
# Get your userId at spontit.com/profile
371+
# Get your secretKey at spontit.com/secret_keys
372+
spontit_src = SpontitResource("my_user_id", "my_secret_key")
346373
example_instance = Examples(spontit_src)
374+
347375
push_response = example_instance.simple_push_example()
348376
print("Simple push example result: " + str(push_response))
349377

build/lib/spontit/resource.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ def push(self,
260260
ios_subtitle=None,
261261
body=None,
262262
push_to_followers=None,
263+
push_to_phone_numbers=None,
264+
push_to_emails=None,
263265
schedule_time_stamp=None,
264266
expiration=None,
265267
link=None,
@@ -276,6 +278,14 @@ def push(self,
276278
:param body: A body of up to 5000 characters to include for when the user opens the push notification. Currently
277279
only available for iOS.
278280
:param push_to_followers: The specific followers to send the push to. A list of strings of the userIds
281+
:param push_to_phone_numbers: The specific users to push to, defined by the phone number they used to sign up.
282+
You can still push to these users even if they don't follow you. However, they have the option to report you
283+
for spam, and you could have your account restricted if multiple users do. They also have the option to follow
284+
you directly from the push.
285+
:param push_to_emails: The specific users to push to, defined by the email they used to sign up.
286+
You can still push to these users even if they don't follow you. However, they have the option to report you
287+
for spam, and you could have your account restricted if multiple users do. They also have the option to follow
288+
you directly from the push.
279289
:param schedule_time_stamp: Schedule the push notification for a later time. Int, epoch timestamp.
280290
:param expiration: Length of time for which the notification should exist. Set to Expiration.
281291
:param link: A link to include in the notification. Appears once the user opens the notification.
@@ -316,7 +326,15 @@ def push(self,
316326

317327
if push_to_followers is not None:
318328
assert type(push_to_followers) == list or type(push_to_followers) == set
319-
payload["individualFollowers"] = list(push_to_followers)
329+
payload["pushToFollowers"] = list(push_to_followers)
330+
331+
if push_to_phone_numbers is not None:
332+
assert type(push_to_phone_numbers) == list or type(push_to_phone_numbers) == set
333+
payload["pushToPhoneNumbers"] = list(push_to_phone_numbers)
334+
335+
if push_to_emails is not None:
336+
assert type(push_to_emails) == list or type(push_to_emails) == set
337+
payload["pushToEmails"] = list(push_to_emails)
320338

321339
if schedule_time_stamp is not None:
322340
if type(schedule_time_stamp) is not int:
-17.2 KB
Binary file not shown.

dist/spontit-1.0.6.tar.gz

-12.1 KB
Binary file not shown.
18.1 KB
Binary file not shown.

dist/spontit-1.0.7.tar.gz

13 KB
Binary file not shown.

0 commit comments

Comments
 (0)