1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with forum poster

Discussion in 'General Programming Chat' started by Ceg3xow, Jul 11, 2011.

  1. Ceg3xow

    Ceg3xow Newbie

    Joined:
    Jul 6, 2011
    Messages:
    18
    Likes Received:
    1
    Hi, i'm building a bot to post on javaBB forums, everything is already done, I can login, find all topics, make an answer, but when I try to post, the form is in AJAX, my bot is in PHP, so I have no idea on what to do, I tried to handle it like a regular form but it didn't work.. can someone help me ? I'm a newbie trying to learn, this is the submit button:

    Code:
    <a href="#" class="formSubmit" tabindex="3">
    this is the message box:

    Code:
    <textarea name="message" id="messageContent" rows="18" wrap="virtual" tabindex="2"></textarea>
    this is the formSubmit function the button send me to:

    Code:
    function formSubmitFunction(e,action, target){
        e.stopPropagation();
        e.preventDefault();
        if ($("#messageContent").attr("value") == undefined || $("#messageContent").attr("value").length < 2){
            alert("A mensagem precisa ter no mÃ*nimo 2 caracteres.");
            $("#messageContent").focus();
            return false;
        }else {
            $("#formSubmit").html('<img src="'+desTheme+'/images/send_post.gif');
            if(action == "post"){
                $("#formAjax").append('<div id="carregando"></div>');
                PostFunctions.insertPost(topicId,$("#messageContent").val(), callbackInsertPost);
            } else {
                var postId = target.replace("#","");
                $("#formAjax").append('<div id="carregando"></div>');           
                PostFunctions.editPost(postId,$("#messageContent").val(), callbackEditPost);
            }
            return false;
        }
    }
    and this is the insertPost function mentioned on it:

    Code:
    function callbackInsertPost(response){
            var result = eval("("+response+")");
            if($("#popup").length){
                $("#popup").remove();
            }
            if(!result.error){
                var returnMessage = "";
                if(result.isForumModerated){
                    returnMessage = '<div id="popup" class="autoClear simple">'
                                        +'Sua mensagem está aguardando a aprovação da moderação.'
                                        +'</div>';
                    $("#carregando").remove();
                    $(actualPostId).prepend(returnMessage);
                    window.setTimeout(function(){
                        $("#popup").fadeOut("slow", function(){
                            $("#popup").remove();
                        });
                    },5000);
                $("#formAjax").remove();
                } else {
                    //console.log(result);
                    window.setTimeout(function(){
                        document.location = "_t_lastpost_"+topicId+"_"+forumId+"?postId="+result.postId;
                    },1500);
                    /*returnMessage = '<div id="popup" class="autoClear simple">'
                                        +'Mensagem enviada com sucesso! Clique neste <a href="_t_lastpost_'+topicId+'_'+forumId+'">link</a> para ver sua mensagem'
                                        +'</div>';*/
                }
            } else {
                if(result.nickname_reproved){
                    document.location = "changenickname.jbb";
                } else {
                    $("#carregando").remove();
                    for(i = 0; i < result.messages.length; i++){
                        $("#formAjax").prepend('<div id="popup" class="autoClear error-post">'
                                            +result.messages[i]+'<br/>'
                                            +'</div>'); 
                        }
                    $.scrollTo("#popup",500);
                    $("#formSubmit").html('<a href="#" class="formSubmit" tabindex="3"><img src="'+baseImages+'/themes/'+desTheme+'/images/pm_send.gif"/></a>');
                    $(".formSubmit").bind("click",function(e){
                        formSubmitFunction(e,"post")
                    });
                }
            }
    }
    can someone help me ? i'm stuck on that for like 4 hours now

    thanks anyways
     
  2. Seuss

    Seuss BANNED BANNED

    Joined:
    Jun 13, 2009
    Messages:
    56
    Likes Received:
    22
    why not just use jQuery's AJAX with your php to send it to their AJAX??
     
  3. masterjani

    masterjani Jr. VIP Jr. VIP

    Joined:
    May 10, 2011
    Messages:
    3,203
    Likes Received:
    372
    Occupation:
    seo professional
    Home Page:
    Better to call the commands by using Jquery and process by ajax