python 代码转PHP 30

#coding=utf-8""""""importbase64importhashlibimporthmacimportjsonimporttimeimportloggi... # coding=utf-8 """

"""
import base64 import hashlib import hmac import json import time import logging import requests
crm_server = 'http://10.12.123.1:19527' pull_clues_api = '/crm/v2/openapi/pull-clues/'

class Signature(object):

def init (self, signature_header=None, timestamp_header=None, timeout=None, token_header=None, digestmod=None):
self.signature_header = signature_header or 'Signature' self.timestamp_header = timestamp_header or 'Timestamp' self.token_header = token_header or 'Access-Token' self.timeout = timeout or 300
self.digestmod = digestmod or hashlib.sha256 self.signature_key = 'Qgr7OEalfhXllcFDGh2l' # self.token = 'Qgr7OEalfhXllcFDGh2l' # token

def generate_signature(self, data, key=None): key = key if key else self.signature_key
signature = hmac.new(key, data, digestmod=self.digestmod). hexdigest()
signature = base64.b64encode(signature) return signature

#pagepage_size,page_size10 #start_timeend_time
def crm_pull_clues(start_time, end_time, page=1, page_size=10): payload = {}

payload["start_time"] = start_time payload["end_time"] = end_time payload["page"] = page payload["page_size"] = page_size timestamp = str(int(time.time())) sig = Signature()
url = crm_server + pull_clues_api data = sig.generate_signature(
'/crm/v2/openapi/pull-clues/?start_time=%s&end_time=%s %s' % (start_time, end_time, timestamp))
headers = {sig.signature_header: data, sig.timestamp_header: timestamp, sig.token_header: sig.token}
headers.update({'Content-Type': 'application/json'}) max_tries = 3 #
resp_data = None while max_tries > 0:
try:
print payload
resp = requests.get(url=url, params=payload, headers=headers) if resp.status_code == 200:
res = json.loads(resp.content) # if res:
return res except Exception as e:
logging.exception("error with %s" % str(e)) resp_data = None
max_tries -= 1 return resp_data

if name == ' main ':
res = crm_pull_clues("2018-07-01", "2018-07-30") if res.get("status") == 0:
data = res.get("data") or [] if res.get("count") > 10:
count = res.get("count") times = count / 10
for i in xrange(times): #10
res = crm_pull_clues("2018-07-01", "2018-07-30", 2 + i) data = data + res.get("data")
print len(data)
展开
 我来答
腾讯电脑管家
2018-11-04 · 百度知道官方认证企业
腾讯电脑管家
腾讯电脑管家是腾讯公司推出的免费安全管理软件,能有效预防和解决计算机上常见的安全风险,并帮助用户解决各种电脑“疑难杂症”、优化系统和网络环境,是中国综合能力最强、最稳定的安全软件。
向TA提问
展开全部
include <QtCore/QCoreApplication>
#include <QAxObject>
#include <Windows.h>
int main(int argc, char *argv[])
{
//OleInitialize(0);
//CoInitialize(0);
QCoreApplication a(argc, argv);
QAxObject *asdfg = new QAxObject("Excel.Application");
return a.exec();
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式