Skip to content

Commit aff22b1

Browse files
committed
Added some changes
1 parent d3e2157 commit aff22b1

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

hcm.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@ def get_access_token(self):
1919
"client_secret": self.client_secret}).encode(),
2020
headers={"Content-type": "application/x-www-form-urlencoded"}
2121
)
22-
2322
return json.loads(urlopen(request).read())['access_token']
2423

2524
def notify_topic_subscribers(self, topic: str, title: str, message_body: str):
2625
payload = {
27-
'validate_only': True,
2826
'message': {
2927
'topic': topic,
30-
'token': [],
3128
'android': {
3229
'notification': {
3330
'title': title,
@@ -46,6 +43,5 @@ def notify_topic_subscribers(self, topic: str, title: str, message_body: str):
4643
headers={"Content-type": "application/json",
4744
"Authorization": f'Bearer {self.get_access_token()}'}
4845
)
49-
50-
return json.loads(urlopen(request).read())['msg'] == 'Success'
51-
46+
response = json.loads(urlopen(request).read())
47+
return response['msg'] == 'Success'

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Python Huawei Cloud Messaging Server
1+
# Python Huawei Cloud Messaging
22

3-
Wrapper api push huawei for sending notification push using python.
3+
Wrapper of api push huawei for sending notification push using python.
44

55
## Example
66

@@ -9,5 +9,5 @@ Wrapper api push huawei for sending notification push using python.
99
CLIENT_ID = "00000000"
1010
CLIENT_SECRET = "0000000000000000000000000000000000000000000000000000000000000000"
1111
12-
HCMNotification(CLIENT_ID, CLIENT_SECRET).notify_topic_subscribers('test_notification', 'test', 'test')
12+
HCMNotification(CLIENT_ID, CLIENT_SECRET).notify_topic_subscribers('test_topic', 'test title', 'test body')
1313
```

0 commit comments

Comments
 (0)