当前位置:编程学习 > VB >>

大家行行好,帮帮小妹下下.困扰我一个月的问题.


    Dim objServerXmlHttp As ServerXMLHTTP60
    Set objServerXmlHttp = New MSXML2.ServerXMLHTTP60
    
    '设置超时
    objServerXmlHttp.setTimeouts 30000, 30000, 30000, 30000
    
    objServerXmlHttp.open "GET", "http://pay.163.com/index.jsp", False
    objServerXmlHttp.setRequestHeader "Accept", " */*"
    objServerXmlHttp.setRequestHeader "Accept-Language", "zh-cn"
    objServerXmlHttp.setRequestHeader "Connection", "Keep-Alive"
    objServerXmlHttp.setRequestHeader "Host", "pay.163.com"
    objServerXmlHttp.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
    objServerXmlHttp.send

    '生成发送的数据
    Dim strPostString As String
    strPostString = "ursName=1@163.com&userName2=1@163.com&cardNo=2222222222222&cardPass=333333333"
    
    '转换字符
    Dim lngPostLenght As Long
    lngPostLenght = Len(strPostString)
    
    objServerXmlHttp.open "POST", "http://ecard.163.com/script/sn_trans/trans?", False
    objServerXmlHttp.setRequestHeader "Accept", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-silverlight, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, */*"
    objServerXmlHttp.setRequestHeader "Accept-Language", "zh-cn"
    objServerXmlHttp.setRequestHeader "Cache-Control", "no-cache"
    objServerXmlHttp.setRequestHeader "Connection", "Keep-Alive"
    objServerXmlHttp.setRequestHeader "Content-Length", lngPostLenght
    objServerXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    objServerXmlHttp.setRequestHeader "Host", "ecard.163.com"
    objServerXmlHttp.setRequestHeader "Referer", "http://pay.163.com/index.jsp"
    objServerXmlHttp.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
    objServerXmlHttp.send strPostString
    
    If InStr(objServerXmlHttp.responseText, "域名以163.com结尾") = 0 Then
        MsgBox "OK"
    Else
        MsgBox "Error"
    End If

    为什么返回的网页老是提示要从 以 163.com 结尾的网址进行访问呢....我在IE里关闭了 Cookie,都可以进行啊.为什么用我写的就不行了呀..

哥哥,姐姐..帮帮我呀..

小妹谢谢大家了...


--------------------编程问答-------------------- 这是从安全性的角度进行的限制,不允许从网站外部调用ASP,否则岂不很容易被攻击吗。 --------------------编程问答-------------------- 请求的时候,信息头会包括客户端的很多信息,服务端据此可以判断是否是来自站内页发出的请求,从而进行拒绝。

可以尝试找找能伪造信息头的工具看看。我倒也有兴趣看看这个帖子的讨论结果有没有什么好办法。 --------------------编程问答-------------------- AJAX本身也对跨域请求做了限制,不能直接使用。
下面是一个实现跨域请求的方法
<script type="text/javascript">   
 //调用jQuery脚本请求   
  jQuery.getScript("http://127.0.0.1:18***/makecall?phone="+phone,function(){alert("拨打成功")});            
</script>  
还有其它一些方法,自己搜索一下“跨域请求”就有了。 --------------------编程问答-------------------- vb能用ajax????????????????????? --------------------编程问答--------------------
引用 4 楼 luofenghen 的回复:
vb能用ajax?????????????????????

呵呵,不知道了吧。何止,VB能做的多了,不要觉得自己了解足够而限制了继续提高的空间啊。
补充:VB ,  网络编程
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,