sc-common-interface 2.3.1__tar.gz → 2.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.3.1
3
+ Version: 2.3.3
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -53,11 +53,27 @@ def end_activity(data):
53
53
  def send__live_comment(data):
54
54
  env = data["env"]
55
55
  key = data["key"]
56
- info = get_live_info(data)
57
- related_post_list = info["data"]["relatedPostList"][0]
58
- page_id = related_post_list["page_id"]
59
- post_id = related_post_list["post_id"]
60
- platform = related_post_list["platform"]
56
+ platform = "FACEBOOK"
57
+ page_id = ""
58
+ post_id = ""
59
+ if "page_id" in data:
60
+ page_id = data['page_id']
61
+ if "platform" in data:
62
+ platform = data['platform']
63
+ if "post_id" in data:
64
+ post_id = data['post_id']
65
+ if page_id == "" or post_id == "":
66
+ info = get_live_info(data)
67
+ platform_list = jsonpath(info, "$..relatedPostList..platform")
68
+ i = platform_list.index(platform)
69
+ page_id = info["data"]["relatedPostList"][i]["page_id"]
70
+ platform = info["data"]["relatedPostList"][i]["platform"]
71
+ post_id = info["data"]["relatedPostList"][i]["post_id"]
72
+ # info = get_live_info(data)
73
+ # related_post_list = info["data"]["relatedPostList"][0]
74
+ # page_id = related_post_list["page_id"]
75
+ # post_id = related_post_list["post_id"]
76
+ # platform = related_post_list["platform"]
61
77
  stamp = int(time.time())
62
78
  num = random.randint(100000, 999999)
63
79
  user_id = "488864%d" % int(time.time())
@@ -72,29 +88,36 @@ def send__live_comment(data):
72
88
  keyword = "接口测试普通留言"
73
89
  if "keyword" in data:
74
90
  keyword = data['keyword']
75
- body = {}
76
- if platform == "FACEBOOK":
77
- body = {"object": "page", "entry": [{"id": page_id, "time": stamp, "changes": [{"field": "feed", "value": {
91
+ body = {"object": "page", "entry": [{"id": page_id, "time": stamp, "changes": [{"field": "feed", "value": {
78
92
  "from": {"id": user_id, "name": name},
79
93
  "post": {"status_type": "added_video", "is_published": True, "updated_time": "2022-11-18T09:57:26+0000",
80
94
  "permalink_url": "https://www.facebook.com/permalink.php?story_fbid=pfbid02jLK3e6YdFSXp2DmD7j7vtStLXoBzTi8rxKrp6jFhVMUTTEgz6qvZA8soR9Uwydd8l&id=107977035056574",
81
95
  "promotion_status": "inactive", "id": post_id}, "message": keyword, "item": "comment",
82
96
  "verb": "add", "post_id": post_id, "comment_id": comment_id,
83
97
  "created_time": stamp, "parent_id": post_id}}]}]}
84
- elif platform == "INSTAGRAM":
98
+ # if platform == "FACEBOOK":
99
+ # body = {"object": "page", "entry": [{"id": page_id, "time": stamp, "changes": [{"field": "feed", "value": {
100
+ # "from": {"id": user_id, "name": name},
101
+ # "post": {"status_type": "added_video", "is_published": True, "updated_time": "2022-11-18T09:57:26+0000",
102
+ # "permalink_url": "https://www.facebook.com/permalink.php?story_fbid=pfbid02jLK3e6YdFSXp2DmD7j7vtStLXoBzTi8rxKrp6jFhVMUTTEgz6qvZA8soR9Uwydd8l&id=107977035056574",
103
+ # "promotion_status": "inactive", "id": post_id}, "message": keyword, "item": "comment",
104
+ # "verb": "add", "post_id": post_id, "comment_id": comment_id,
105
+ # "created_time": stamp, "parent_id": post_id}}]}]}
106
+ if platform == "INSTAGRAM":
85
107
  body = {"entry": [{"id": page_id, "time": stamp, "changes": [{"value": {"from": {"id": user_id,
86
108
  "username": name},
87
109
  "media": {"id": post_id,
88
110
  "media_product_type": "FEED"},
89
111
  "id": comment_id, "text": keyword},
90
112
  "field": "comments"}]}], "object": "instagram"}
91
-
113
+ print(body)
92
114
  url = "%s/facebook/webhook" % env
93
115
  sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
94
116
  signData = sign_text.hexdigest()
95
117
  # print("body", json.dumps(body))
96
118
  header = {"Content-Type": "application/json", "x-hub-signature": "sha1=%s" % signData}
97
119
  response = requests.post(url, headers=header, data=json.dumps(body))
120
+ print(response.text)
98
121
  return user_id, name, comment_id
99
122
 
100
123
  def send_mc_message(data):
@@ -122,12 +145,18 @@ def send_mc_message(data):
122
145
  i = platform_list.index(platform)
123
146
  page_id = info["data"]["relatedPostList"][i]["page_id"]
124
147
  platform = info["data"]["relatedPostList"][i]["platform"]
125
- body = {}
126
- if platform.upper()=="FACEBOOK":
127
- body = {"entry":[{"id":"%s"%page_id,"messaging":[{"message":
128
- {"mid":"m_hhAqPhSlMTY4En2oWjSB59T3BFjeU97DdDV4WHr3DLWnPrO0iCsjQlG3hBN%d-sBlT26-6oNg"%stamp,"text":"%s"%message},
129
- "recipient":{"id":"%s"%page_id},"sender":{"id":"%s"%user_id},"timestamp":stamp}],"time":stamp}],"object":"page"}
130
- elif platform.upper()=="INSTAGRAM":
148
+ body = {"entry": [{"id": "%s" % page_id, "messaging": [{"message":
149
+ {
150
+ "mid": "m_hhAqPhSlMTY4En2oWjSB59T3BFjeU97DdDV4WHr3DLWnPrO0iCsjQlG3hBN%d-sBlT26-6oNg" % stamp,
151
+ "text": "%s" % message},
152
+ "recipient": {"id": "%s" % page_id},
153
+ "sender": {"id": "%s" % user_id}, "timestamp": stamp}],
154
+ "time": stamp}], "object": "page"}
155
+ # if platform.upper()=="FACEBOOK":
156
+ # body = {"entry":[{"id":"%s"%page_id,"messaging":[{"message":
157
+ # {"mid":"m_hhAqPhSlMTY4En2oWjSB59T3BFjeU97DdDV4WHr3DLWnPrO0iCsjQlG3hBN%d-sBlT26-6oNg"%stamp,"text":"%s"%message},
158
+ # "recipient":{"id":"%s"%page_id},"sender":{"id":"%s"%user_id},"timestamp":stamp}],"time":stamp}],"object":"page"}
159
+ if platform.upper()=="INSTAGRAM":
131
160
  body={"object":"instagram","entry":[{"time":stamp,"id":"%s"%page_id,"messaging":[{"sender":{"id":"%s"%user_id},"recipient":{"id":"%s"%page_id},
132
161
  "timestamp":stamp,"message":{"mid":"aWdfZAG1faXRlbToxOklHTWVzc2FnZAUlEOjE3ODQxNDUwMzgwODgwNTMzOjM0MDI4MjM2Njg0MTcxMDMwMTI0NDI3NjAyNDExMzcwMDc2NTA5MDozMTgzODU0Mzg3NTY4MDYwMTE3ODUxOTE2MD%d"%stamp,"text":"%s"%message}}]}]}
133
162
  url = "%s/facebook/webhook" % env
@@ -330,7 +359,7 @@ def get_broadcast_list(data):
330
359
  for i,value in enumerate(name_list):
331
360
  if value==name:
332
361
  broadcast_id =broadcast_id_list[i]
333
- return broadcast_id,name
362
+ return broadcast_id,reponse
334
363
 
335
364
  def get_broadcast_detail(data):
336
365
  env = data["env"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.3.1
3
+ Version: 2.3.3
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='sc-common-interface',
5
- version='2.3.1',
5
+ version='2.3.3',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),