sc-common-interface 2.3.4__tar.gz → 2.3.5__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.
- {sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/PKG-INFO +1 -1
- {sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface/LiveCommonInterface.py +2 -1
- sc-common-interface-2.3.5/sc_common_interface/McCommonInterface.py +130 -0
- {sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface/PostCommonInterface.py +26 -6
- {sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface.egg-info/PKG-INFO +1 -1
- {sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface.egg-info/SOURCES.txt +1 -0
- {sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/setup.py +1 -1
- {sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface/Platform.py +0 -0
- {sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface/__init__.py +0 -0
- {sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface.egg-info/dependency_links.txt +0 -0
- {sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface.egg-info/requires.txt +0 -0
- {sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface.egg-info/top_level.txt +0 -0
- {sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/setup.cfg +0 -0
{sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface/LiveCommonInterface.py
RENAMED
|
@@ -145,9 +145,10 @@ def send_mc_message(data):
|
|
|
145
145
|
i = platform_list.index(platform)
|
|
146
146
|
page_id = info["data"]["relatedPostList"][i]["page_id"]
|
|
147
147
|
platform = info["data"]["relatedPostList"][i]["platform"]
|
|
148
|
+
mid = "m_hhAqPhSlMTY4En2oWjSB59T3BFjeU97DdDV4WHr3DLWnPrO0iCsjQlG3hBN%d-sBlT26-6oNg" % stamp
|
|
148
149
|
body = {"entry": [{"id": "%s" % page_id, "messaging": [{"message":
|
|
149
150
|
{
|
|
150
|
-
"mid":
|
|
151
|
+
"mid": mid,
|
|
151
152
|
"text": "%s" % message},
|
|
152
153
|
"recipient": {"id": "%s" % page_id},
|
|
153
154
|
"sender": {"id": "%s" % user_id}, "timestamp": stamp}],
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
import requests
|
|
3
|
+
import json
|
|
4
|
+
from jsonpath import jsonpath
|
|
5
|
+
import time
|
|
6
|
+
import random
|
|
7
|
+
import hmac
|
|
8
|
+
from hashlib import sha1
|
|
9
|
+
import random
|
|
10
|
+
|
|
11
|
+
def send_mc_message(data):
|
|
12
|
+
env = data["env"]
|
|
13
|
+
key = data["key"]
|
|
14
|
+
stamp = int(time.time()*1000)
|
|
15
|
+
user_id = "488864%d" % int(time.time())
|
|
16
|
+
if "user_id" in data:
|
|
17
|
+
user_id = data['user_id']
|
|
18
|
+
name = "test live%d" % int(time.time())
|
|
19
|
+
if "name" in data:
|
|
20
|
+
name = data['name']
|
|
21
|
+
message = "接口测试普通留言"
|
|
22
|
+
if "message" in data:
|
|
23
|
+
message = data['message']
|
|
24
|
+
page_id = ""
|
|
25
|
+
if "page_id" in data:
|
|
26
|
+
page_id = data['page_id']
|
|
27
|
+
platform = "FACEBOOK"
|
|
28
|
+
if "platform" in data:
|
|
29
|
+
platform = data['platform']
|
|
30
|
+
type = "text"
|
|
31
|
+
if "type" in data:
|
|
32
|
+
type = data["type"]
|
|
33
|
+
mid = "m_hhAqPhSlMTY4En2oWjSB59T3BFjeU97DdDV4WHr3DLWnPrO0iCsjQlG3hBN%d-sBlT26-6oNg" % stamp
|
|
34
|
+
if "mid" in data:
|
|
35
|
+
mid = data["mid"]
|
|
36
|
+
body={}
|
|
37
|
+
if "body" in data:
|
|
38
|
+
body = data["body"]
|
|
39
|
+
if platform.upper() == "FACEBOOK":
|
|
40
|
+
if type=="text":
|
|
41
|
+
body = {"entry": [{"id": "%s" % page_id, "messaging": [{"message":
|
|
42
|
+
{
|
|
43
|
+
"mid": mid,
|
|
44
|
+
"text": "%s" % message},
|
|
45
|
+
"recipient": {"id": "%s" % page_id},
|
|
46
|
+
"sender": {"id": "%s" % user_id}, "timestamp": stamp}],
|
|
47
|
+
"time": stamp}], "object": "page"}
|
|
48
|
+
elif type=="gif":
|
|
49
|
+
body = {"entry": [{"id": "%s" % page_id, "messaging": [{"message":{
|
|
50
|
+
"mid": mid,
|
|
51
|
+
"attachments": [{"type": "image", "payload": {
|
|
52
|
+
"url": "https://cdn.fbsbx.com/v/t59.2708-21/267652425_2742112282760223_8342075864203047385_n.gif?_nc_cat=107\u0026ccb=1-7\u0026_nc_sid=cf94fc\u0026_nc_ohc=aa48LfY75iUQ7kNvgFdUHh0\u0026_nc_ht=cdn.fbsbx.com\u0026oh=03_Q7cD1QE9ftiyK21HTVYBWqW8JAaA-rEYS0ydqSuWlLUW5LwslA\u0026oe=66F73B3C"}}]
|
|
53
|
+
},
|
|
54
|
+
"recipient": {"id": "%s" % page_id},
|
|
55
|
+
"sender": {"id": "%s" % user_id}, "timestamp": stamp}],
|
|
56
|
+
"time": stamp}], "object": "page"}
|
|
57
|
+
elif type=="picture":
|
|
58
|
+
body = {"entry": [{"id": "%s" % page_id, "messaging": [{"message": {
|
|
59
|
+
"mid": mid,
|
|
60
|
+
"attachments": [{"type": "image", "payload": {
|
|
61
|
+
"url": "https://cdn.fbsbx.com/v/t59.2708-21/267652425_2742112282760223_8342075864203047385_n.gif?_nc_cat=107\u0026ccb=1-7\u0026_nc_sid=cf94fc\u0026_nc_ohc=aa48LfY75iUQ7kNvgFdUHh0\u0026_nc_ht=cdn.fbsbx.com\u0026oh=03_Q7cD1QE9ftiyK21HTVYBWqW8JAaA-rEYS0ydqSuWlLUW5LwslA\u0026oe=66F73B3C"}}]
|
|
62
|
+
},
|
|
63
|
+
"recipient": {"id": "%s" % page_id},
|
|
64
|
+
"sender": {"id": "%s" % user_id}, "timestamp": stamp}],
|
|
65
|
+
"time": stamp}], "object": "page"}
|
|
66
|
+
elif type =="template":
|
|
67
|
+
body = {"object":"page","entry":[{"id":"%s" % page_id,"time":stamp,"messaging":[{"sender":{"id":"%s" % user_id},"recipient":{"id":"%s" % page_id},"timestamp":stamp,"message":{"mid":mid,"text":"Hi,name1716183125。感謝您的支持和信任。這是您的訂單,請盡快完成付款。\n\n訂單編號:\n#20240926134206449\n創建時間:\n2024-09-26 20:42:10\n\n待付款金額:฿70.11","is_echo":True,"app_id":197583024153108,"metadata":"MC3.0_61b096beb7bef100245dbd8b","attachments":[{"type":"template","payload":{"template_type":"button","buttons":[{"type":"web_url","url":"https://message-center.shoplineapp.com/admin/user/order-checkout/634553c44e79c6f331c4ba1fe744199b?merchant_id=61b096beb7bef100245dbd8b\u0026locale=zh-hant","title":"去支付"}]}}]}}]}],"Fbe":False}
|
|
68
|
+
elif type == "video":
|
|
69
|
+
body = {"entry": [{"id": "%s" % page_id, "messaging": [{"message": {
|
|
70
|
+
"mid": mid,
|
|
71
|
+
"attachments": [{"type": "video", "payload": {
|
|
72
|
+
"url": "https://video.xx.fbcdn.net/v/t42.3356-2/432615672_8029825447033772_7739712335639564092_n.mp4?_nc_cat=108\u0026ccb=1-7\u0026_nc_sid=4f86bc\u0026_nc_ohc=b4-Y6xX1rtUQ7kNvgFmSRk_\u0026_nc_ht=video.xx\u0026_nc_gid=A-Pz8fTYZc89Un5kLMoLJMv\u0026oh=03_Q7cD1QG_WI1uD77MmN9xKAxXx3tZOL8muTvMgCFpNENoI9S7lw\u0026oe=66F74642"}}]
|
|
73
|
+
},
|
|
74
|
+
"recipient": {"id": "%s" % page_id},
|
|
75
|
+
"sender": {"id": "%s" % user_id}, "timestamp": stamp}],
|
|
76
|
+
"time": stamp}], "object": "page"}
|
|
77
|
+
elif type == "audio":
|
|
78
|
+
body = {"entry": [{"id": "%s" % page_id, "messaging": [{"message": {
|
|
79
|
+
"mid": mid,
|
|
80
|
+
"attachments": [{"type": "audio", "payload": {
|
|
81
|
+
"url": "https://cdn.fbsbx.com/v/t59.3654-21/461150567_1761086874427012_6172811562215217140_n.wav/audio_clip.wav?_nc_cat=101\u0026ccb=1-7\u0026_nc_sid=d61c36\u0026_nc_ohc=L5BQtwl4CAgQ7kNvgGHihOx\u0026_nc_ht=cdn.fbsbx.com\u0026_nc_gid=AP5AR1-XZNRACEs4Q2hlS7w\u0026oh=03_Q7cD1QGwgqbQ-_sc078THHpQqaTSy83Xg9FpPv9DfswxesIBWw\u0026oe=66F754B6"}}]
|
|
82
|
+
},
|
|
83
|
+
"recipient": {"id": "%s" % page_id},
|
|
84
|
+
"sender": {"id": "%s" % user_id}, "timestamp": stamp}],
|
|
85
|
+
"time": stamp}], "object": "page"}
|
|
86
|
+
elif type == "file":
|
|
87
|
+
body = {"entry": [{"id": "%s" % page_id, "messaging": [{"message": {
|
|
88
|
+
"mid": mid,
|
|
89
|
+
"attachments": [{"type": "file", "payload": {
|
|
90
|
+
"url": "https://cdn.fbsbx.com/v/t59.2708-21/372887834_1477966239657135_964223859622790441_n.xls/shopline.xls?_nc_cat=104\u0026ccb=1-7\u0026_nc_sid=2b0e22\u0026_nc_ohc=HD1EWsL_GAMQ7kNvgH1XAqH\u0026_nc_ht=cdn.fbsbx.com\u0026_nc_gid=AbQ5mUwXgVRLcTg_SDMsXuQ\u0026oh=03_Q7cD1QGbJ5rcs9fnkSYImAoSTVMEYZzCn0Uop0a1LT06MItUHw\u0026oe=66F743BF"}}]
|
|
91
|
+
},
|
|
92
|
+
"recipient": {"id": "%s" % page_id},
|
|
93
|
+
"sender": {"id": "%s" % user_id}, "timestamp": stamp}],
|
|
94
|
+
"time": stamp}], "object": "page"}
|
|
95
|
+
elif type == "image":
|
|
96
|
+
body = {"entry": [{"id": "%s" % page_id, "messaging": [{"message": {
|
|
97
|
+
"mid": mid,
|
|
98
|
+
"attachments": [{"type": "image", "payload": {
|
|
99
|
+
"url": "https://scontent.xx.fbcdn.net/v/t1.15752-9/453334896_849046190144775_2687107896488738244_n.png?_nc_cat=106\u0026ccb=1-7\u0026_nc_sid=fc17b8\u0026_nc_ohc=PHylk2lIl2UQ7kNvgE62hJr\u0026_nc_ad=z-m\u0026_nc_cid=0\u0026_nc_ht=scontent.xx\u0026_nc_gid=A1lL9UZ_Rb3le2HUKS5-i7y\u0026oh=03_Q7cD1QFfWFzhNi_lgujYyTyBM5c5YPONyX7YXKLN4du04YHU7A\u0026oe=671CD669"}}]
|
|
100
|
+
},
|
|
101
|
+
"recipient": {"id": "%s" % page_id},
|
|
102
|
+
"sender": {"id": "%s" % user_id}, "timestamp": stamp}],
|
|
103
|
+
"time": stamp}], "object": "page"}
|
|
104
|
+
elif type == "product":
|
|
105
|
+
body = {"entry": [{"id": "%s" % page_id, "messaging": [{"message": {
|
|
106
|
+
"mid": mid,
|
|
107
|
+
"text":"Hi!快來看看我們為您挑選的精選商品👇\nhttps://shln.me/HT/gb0sQ"
|
|
108
|
+
},
|
|
109
|
+
"recipient": {"id": "%s" % page_id},
|
|
110
|
+
"sender": {"id": "%s" % user_id}, "timestamp": stamp}],
|
|
111
|
+
"time": stamp}], "object": "page"}
|
|
112
|
+
|
|
113
|
+
if platform.upper()=="INSTAGRAM":
|
|
114
|
+
body={"object":"instagram","entry":[{"time":stamp,"id":"%s"%page_id,"messaging":[{"sender":{"id":"%s"%user_id},"recipient":{"id":"%s"%page_id},
|
|
115
|
+
"timestamp":stamp,"message":{"mid":mid,"text":"%s"%message}}]}]}
|
|
116
|
+
url = "%s/facebook/webhook" % env
|
|
117
|
+
sign_text = hmac.new(key.encode("utf-8"), json.dumps(body).encode("utf-8"), sha1)
|
|
118
|
+
signData = sign_text.hexdigest()
|
|
119
|
+
header = {"Content-Type": "application/json", "x-hub-signature": "sha1=%s" % signData}
|
|
120
|
+
response = requests.post(url, headers=header, data=json.dumps(body))
|
|
121
|
+
return user_id, name,mid
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if __name__=="__main__":
|
|
125
|
+
data = {'env': 'https://front-admin-preview.shoplineapp.com', 'key': '5e3bba98882fc0fb22a0607238bc5b8f', 'page_id': '108513131786753'}
|
|
126
|
+
data["type"] = "product"
|
|
127
|
+
user_id, name,mid = send_mc_message(data)
|
|
128
|
+
# data["mid"] = mid
|
|
129
|
+
# send_mc_message(data)
|
|
130
|
+
|
{sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface/PostCommonInterface.py
RENAMED
|
@@ -782,7 +782,17 @@ def get_payment(data):
|
|
|
782
782
|
headers = data["headers"]
|
|
783
783
|
url ="%s/openApi/proxy/v1/payments?page=1&per_page=10&include_fields[]=config_data.tappay"%env
|
|
784
784
|
response = requests.get(url, headers=headers).json()
|
|
785
|
-
|
|
785
|
+
payment_types = [item["type"] for item in response["data"]["items"]]
|
|
786
|
+
payment_id = ""
|
|
787
|
+
for payment in payment_types:
|
|
788
|
+
# print(delivery)
|
|
789
|
+
if payment == "bank_transfer":
|
|
790
|
+
index = payment_types.index(payment)
|
|
791
|
+
payment_info = response["data"]["items"][index]
|
|
792
|
+
payment_id = payment_info["id"]
|
|
793
|
+
break
|
|
794
|
+
if payment_id == "":
|
|
795
|
+
payment_id = response["data"]["items"][0]["id"]
|
|
786
796
|
return payment_id,response
|
|
787
797
|
|
|
788
798
|
def get_delivery(data):
|
|
@@ -794,9 +804,20 @@ def get_delivery(data):
|
|
|
794
804
|
# print("物流data",data)
|
|
795
805
|
env = data["env"]
|
|
796
806
|
headers = data["headers"]
|
|
797
|
-
url = "%s/openApi/proxy/v1/delivery_options?page=1&per_page=
|
|
807
|
+
url = "%s/openApi/proxy/v1/delivery_options?page=1&per_page=998"%env
|
|
798
808
|
response = requests.get(url, headers=headers).json()
|
|
799
|
-
|
|
809
|
+
# print(response)
|
|
810
|
+
delivery_types = [item["region_type"] for item in response["data"]["items"]]
|
|
811
|
+
delivery_id = ""
|
|
812
|
+
for delivery in delivery_types:
|
|
813
|
+
# print(delivery)
|
|
814
|
+
if delivery == "custom":
|
|
815
|
+
index = delivery_types.index(delivery)
|
|
816
|
+
delivery_info = response["data"]["items"][index]
|
|
817
|
+
delivery_id = delivery_info["id"]
|
|
818
|
+
break
|
|
819
|
+
if delivery_id=="":
|
|
820
|
+
delivery_id = response["data"]["items"][0]["id"]
|
|
800
821
|
return delivery_id,response
|
|
801
822
|
|
|
802
823
|
def get_comment_user(data):
|
|
@@ -971,7 +992,7 @@ def manual_order(data):
|
|
|
971
992
|
"source_data": {"type": "fb", "source_id": page_id}, "customer_phone_country_code": "86",
|
|
972
993
|
"postcode": postcode}
|
|
973
994
|
res = requests.post(url,headers=headers,json=body)
|
|
974
|
-
print("创建订单返回",res.text)
|
|
995
|
+
# print("创建订单返回",res.text)
|
|
975
996
|
#获取订单ID
|
|
976
997
|
orderNumber = ""
|
|
977
998
|
if res.status_code==200:
|
|
@@ -1517,5 +1538,4 @@ def get_mc_order_link(url):
|
|
|
1517
1538
|
|
|
1518
1539
|
|
|
1519
1540
|
if __name__=="__main__":
|
|
1520
|
-
pass
|
|
1521
|
-
|
|
1541
|
+
pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface.egg-info/requires.txt
RENAMED
|
File without changes
|
{sc-common-interface-2.3.4 → sc-common-interface-2.3.5}/sc_common_interface.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|