Пример #1
0
class UseMasterController(Controller):
    apiaddress = None

    def __init__(self):
        self.apiaddress = KahlaApiAddressService()

    # 定义参数
    def get_options(self):
        return []

    # 处理输入参数, 检查合法性
    def run(self):
        # 这条必须编写, 并且带上传入的参数
        self.compute()

    # 处理业务逻辑
    def main(self):
        self.apiaddress.usemaster()
        return {}
class KahlaFriendShipApiService(object):
	apiaddress = None

	def __init__(self):
		self.apiaddress = KahlaApiAddressService()
		self.storagecookie = StorageCookieService()
	
	def Friends(self):
		r = requests.get("{0}/Friendship/MyFriends?orderByName=true".format(self.apiaddress.getaddress()),
				   cookies=self.storagecookie.get())
		
		return r
	
	def Me(self):
            r = requests.get("{0}/Auth/Me".format(self.apiaddress.getaddress()), cookies=self.storagecookie.get())
		
            return r
	
	def UserDetail(self, userid):
		r = requests.get("{0}/Friendship/UserDetail?id={1}".format(self.apiaddress.getaddress(), str(userid)),
						cookies=self.storagecookie.get())

		return r
	
	def DeleteFriend(self, userid):
		r = requests.post("{0}/Friendship/DeleteFriend".format(self.apiaddress.getaddress()), data={
			"id": str(userid)
		},
		cookies=self.storagecookie.get())

		return r
	
	def LeaveGroup(self, groupname):
		r = requests.post("{0}/Groups/LeaveGroup".format(self.apiaddress.getaddress()), data={
			"groupName": groupname
		},
		cookies=self.storagecookie.get())

		return r
Пример #3
0
class KahlaAuthApiService(object):
    apiaddress = None

    def __init__(self):
        self.apiaddress = KahlaApiAddressService()
        self.storagecookie = StorageCookieService()

    def AuthByPassword(self, email, password):
        r = requests.post("{0}/Auth/AuthByPassword".format(
            self.apiaddress.getaddress()),
                          data={
                              "Email": email,
                              "Password": password
                          })

        return r

    def InitPusher(self):
        r = requests.get("{0}/Auth/InitPusher".format(
            self.apiaddress.getaddress()),
                         cookies=self.storagecookie.get())

        return r
Пример #4
0
class KahlaConversationApiService(object):
    def __init__(self):
        self.apiaddress = KahlaApiAddressService()
        self.storagecookie = StorageCookieService()

    def ConversationDetail(self, conversationid):
        r = requests.get("{0}/Conversation/ConversationDetail?id={1}".format(
            self.apiaddress.getaddress(), str(conversationid)),
                         cookies=self.storagecookie.get())

        return r

    def SendMessage(self, conversationId, Message):
        r = requests.post("{0}/Conversation/SendMessage".format(
            self.apiaddress.getaddress()),
                          data={
                              "Id": conversationId,
                              "Content": Message
                          },
                          cookies=self.storagecookie.get())

        return r

    def GetMesssages(self, conversationId, take):
        r = requests.get("{0}/Conversation/GetMessage?Id={1}&take={2}".format(
            self.apiaddress.getaddress(), str(conversationId), str(take)),
                         cookies=self.storagecookie.get())

        return r

    def FileDownloadAddress(self, filekey):
        r = requests.post("{0}/Files/FileDownloadAddress".format(
            self.apiaddress.getaddress()),
                          data={"FileKey": filekey},
                          cookies=self.storagecookie.get())

        return r
class KahlaSignInStatusCheckService(object):
    def __init__(self):
        self.storagecookie = StorageCookieService()
        self.apiaddress = KahlaApiAddressService()

    def check(self):
        if os.path.exists("{0}/user.cookie.bin".format(
                HomeFloderConfig().getconfigpath())) == True:
            cookies = self.storagecookie.get()
            result = json.loads(
                requests.post("{0}/Auth/SignInStatus".format(
                    self.apiaddress.getaddress()),
                              cookies=cookies).text)
            if result["value"] == True:
                return True
            else:
                return False
        else:
            return False
Пример #6
0
 def __init__(self):
     self.apiaddress = KahlaApiAddressService()
Пример #7
0
	def __init__(self):
		self.apiaddress = KahlaApiAddressService()
		self.authapiservice = KahlaAuthApiService()
		self.checkstatusservice = KahlaSignInStatusCheckService()
Пример #8
0
 def __init__(self):
     self.apiaddress = KahlaApiAddressService()
     self.storagecookie = StorageCookieService()