代码如下:
import urllib.parse,os.path,time,sys,re,urllib.request
from http.client import HTTPSConnection
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebKitWidgets import *
from PyQt5.QtNetwork import *
#path
ospath=sys.path[0]
if len(ospath)!=3:
ospath+='//'
ospath=ospath.replace('//','/')
#api
class Api:
def getOpenid(self,token):
url="https://graph.qq.com/oauth2.0/me?access_token=%s" % token
u=urllib.request.urlopen(url)
data=u.read()
try:
data=data.decode('utf-8')
except:
data=data.decode('gbk')
openid=re.findall('"openid":"(.+?)"',data)[0]
return openid
def qq(self,token,status,pic):
fSize=os.path.getsize(pic)
BOUNDARY="$-img-lufei-goodboy-$"
CRLF='/r/n'
data=[
'--'+BOUNDARY,
'Content-Disposition: form-data; name="access_token"',
'',
token,
'--'+BOUNDARY,
'Content-Disposition: form-data; name="openid"',
'',
self.getOpenid(token),
'--'+BOUNDARY,
'Content-Disposition: form-data; name="oauth_consumer_key"',
'',
'100451446',
#status
'--'+BOUNDARY,
'Content-Disposition: form-data; name="content"',
'',
status,
#pic
新闻热点
疑难解答