吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1458|回复: 9
收起左侧

[求助] VB 中的inet控件和WebBrowser控件调用失败

[复制链接]
英姿飒爽d木叶君 发表于 2019-12-29 13:47
想用VB调用小I机器人接口,但是试了VB中的INET控件WebBrowser控件,均无法返回正确的答案,用IE也无法正确返回,但是用360极速浏览器却可以返回正确的答案,求助大佬们应该怎么办呢
语句如下:
语句= "http://i.xiaoi.com/robot/webrobot?data={""sessionId"":""8e52024188u65e13782"",""robotId"":""webbot"",""userId"":""b472189e640448c8927f3b982d945886"",""body"":{""content"":""深圳天气""},""type"":""txt""}"
被Vb运行后的网址:http://i.xiaoi.com/robot/webrobot?data={"sessionId":"8e52024188u65e13782","robotId":"webbot","userId":"b472189e640448c8927f3b982d945886","body":{"content":"深圳天气"},"type":"txt"}

正确的返回结果应该是:
{"robotId":"webbot","userId":"5b9e2d5fd388466b91466addabdcc102","sessionId":"b358c82a48e94185baee2dd420c2cf5a","type":"txt","body":{"fontStyle":0,"fontColor":0,"content":"深圳今天15℃~19℃ 中雨转小雨 0-3级 \u003c5.4m/s\r\n建议着薄外套、开衫牛仔衫裤等服装。年老体弱者应适当添加衣物,宜着夹克衫、薄毛衣等。\r\n","emoticons":{}}}

求助,应该咋办呀,急,在线等!

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Monitor 发表于 2019-12-29 13:58
这种情况第一感觉是引号问题
 楼主| 英姿飒爽d木叶君 发表于 2019-12-29 13:59
Monitor 发表于 2019-12-29 13:58
这种情况第一感觉是引号问题

但是被Vb运行过后的网址可以被360浏览器给打开
Monitor 发表于 2019-12-29 14:15
http://i.xiaoi.com/robot/webrobot?&callback=__webrobot_processMsg&data=%7B%22sessionId%22%3A%2229ad6f9398124ea3b097b8569c0aa158%22%2C%22robotId%22%3A%22webbot%22%2C%22userId%22%3A%224a9d9b312ac1410e98850eb2d78ef079%22%2C%22body%22%3A%7B%22content%22%3A%22%E6%B7%B1%E5%9C%B3%E5%A4%A9%E6%B0%94%22%7D%2C%22type%22%3A%22txt%22%7D&ts=1577600023095


[Asm] 纯文本查看 复制代码
http://i.xiaoi.com/robot/webrobot?&callback=__webrobot_processMsg&data=%7B%22sessionId%22%3A%2229ad6f9398124ea3b097b8569c0aa158%22%2C%22robotId%22%3A%22webbot%22%2C%22userId%22%3A%224a9d9b312ac1410e98850eb2d78ef079%22%2C%22body%22%3A%7B%22content%22%3A%22%E6%B7%B1%E5%9C%B3%E5%A4%A9%E6%B0%94%22%7D%2C%22type%22%3A%22txt%22%7D&ts=1577600023095
 楼主| 英姿飒爽d木叶君 发表于 2019-12-29 17:58
Monitor 发表于 2019-12-29 14:15
http://i.xiaoi.com/robot/webrobot?&callback=__webrobot_processMsg&data=%7B%22sessionId%22%3A%2229ad6 ...

谢谢您的解答,但是我的目的不是为了获得深圳天气,如果这样写的话,我怎么加变量了呢
Monitor 发表于 2019-12-29 18:00
本帖最后由 Monitor 于 2019-12-29 18:02 编辑
英姿飒爽d木叶君 发表于 2019-12-29 17:58
谢谢您的解答,但是我的目的不是为了获得深圳天气,如果这样写的话,我怎么加变量了呢

http://i.xiaoi.com/robot/webrobot?&callback=__webrobot_processMsg&data=%7B%22sessionId%22%3A%2229ad6f9398124ea3b097b8569c0aa158%22%2C%22robotId%22%3A%22webbot%22%2C%22userId%22%3A%224a9d9b312ac1410e98850eb2d78ef079%22%2C%22body%22%3A%7B%22content%22%3A%22%E6%B7%B1%E5%9C%B3%E5%A4%A9%E6%B0%94%22%7D%2C%22type%22%3A%22txt%22%7D&ts=1577600023095


等于


http://i.xiaoi.com/robot/webrobo ... rocessMsg&data={"sessionId":"29ad6f9398124ea3b097b8569c0aa158","robotId":"webbot","userId":"4a9d9b312ac1410e98850eb2d78ef079","body":{"content":"深圳天气"},"type":"txt"}&ts=1577600023095

Monitor 发表于 2019-12-29 18:03
Monitor 发表于 2019-12-29 18:00
http://i.xiaoi.com/robot/webrobot?&callback=__webrobot_processMsg&data=%7B%22sessionId%22%3A%2229a ...

URL编码一下,这样在代码里面也不用出现引号了
 楼主| 英姿飒爽d木叶君 发表于 2019-12-29 18:32
Monitor 发表于 2019-12-29 18:03
URL编码一下,这样在代码里面也不用出现引号了

不太会用,您方便告知怎么将变量解码吗?我解码后,好像不太对了
 楼主| 英姿飒爽d木叶君 发表于 2019-12-29 21:59
Monitor 发表于 2019-12-29 18:00
http://i.xiaoi.com/robot/webrobot?&callback=__webrobot_processMsg&data=%7B%22sessionId%22%3A%2229a ...

请问下您使用的编码工具是哪一个呢,我找了网上的在线编码工具,编出来的都不行
Monitor 发表于 2019-12-31 10:30
英姿飒爽d木叶君 发表于 2019-12-29 21:59
请问下您使用的编码工具是哪一个呢,我找了网上的在线编码工具,编出来的都不行

[Asm] 纯文本查看 复制代码
'编码函数
Public Function UTF8EncodeURI(szInput)
    Dim wch, uch, szRet
    Dim X
    Dim nAsc, nAsc2, nAsc3
    If szInput = "" Then
        UTF8EncodeURI = szInput
        Exit Function
    End If
    For X = 1 To Len(szInput)
        wch = Mid(szInput, X, 1)
        nAsc = AscW(wch)
        If nAsc < 0 Then nAsc = nAsc + 65536
        If (nAsc And &HFF80) = 0 Then
            szRet = szRet & wch
        Else
            If (nAsc And &HF000) = 0 Then
                uch = "%" & Hex(((nAsc \ 2 ^ 6)) Or &HC0) & Hex(nAsc And &H3F Or &H80)
                szRet = szRet & uch
            Else
                uch = "%" & Hex((nAsc \ 2 ^ 12) Or &HE0) & "%" & _
                Hex((nAsc \ 2 ^ 6) And &H3F Or &H80) & "%" & _
                Hex(nAsc And &H3F Or &H80)
                szRet = szRet & uch
            End If
        End If
    Next
    UTF8EncodeURI = szRet
End Function



Private Sub Command1_Click()
    Dim a, b, c
    a = "http://i.xiaoi.com/robot/webrobot?&callback=__webrobot_processMsg&data=%7B%22sessionId%22%3A%2229ad6f9398124ea3b097b8569c0aa158%22%2C%22robotId%22%3A%22webbot%22%2C%22userId%22%3A%224a9d9b312ac1410e98850eb2d78ef079%22%2C%22body%22%3A%7B%22content%22%3A%22"
    b = "%22%7D%2C%22type%22%3A%22txt%22%7D"
    c = a & UTF8EncodeURI("深圳天气") & b
   '改上面的中文为对话的内容
    WebBrowser1.Navigate (c)
End Sub
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-27 00:16

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表