some trouble about the "POST Request"

work4seo

Новичок
Регистрация
10.06.2012
Сообщения
27
Благодарностей
0
Баллы
0
i want to use "POST Request" to login the wordpress blog and post a article

when i fill the data as "log=testzp&pwd=admin888&wp-submit=Log+In&redirect_to=https%3A%2F%2Ftestzp.wordpress.com%2Fwp-admin%2F&testcookie=1"

zp didn't login the blog

the same trouble happened when i posting the article

when i run debug the zp showed "OK"

question:
How to determine the "POST Request" had been successfully executed

here is the template
http://www.mediafire.com/?07vnc8trlealzlk
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113
You cannot send cookies with POST request in current version of ZP.
 
  • Спасибо
Реакции: work4seo

work4seo

Новичок
Регистрация
10.06.2012
Сообщения
27
Благодарностей
0
Баллы
0

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113
You can save profile (which contains cookies) in 1 project and load it in other ones.

 
  • Спасибо
Реакции: work4seo

traumatic

Client
Регистрация
22.10.2012
Сообщения
10
Благодарностей
1
Баллы
0
i just ran into the same problem... having to POST with cookies. Saving/loading profiles doesn't really help here, does it?
I wonder if there's some sort of workaround as long as ZennoPoster's built-in POST doesn't support cookies.

Maybe via direct C# code utilizing CookieContainer() or something? Any help would be greatly appreciated, thank you!
 

zon3d

Client
Регистрация
22.03.2012
Сообщения
29
Благодарностей
1
Баллы
3
Yes why does ZP not have this feature yet? I requested this months ago and I think this is such an important feature to have.
 

traumatic

Client
Регистрация
22.10.2012
Сообщения
10
Благодарностей
1
Баллы
0
After fiddling around a bit I think it's not possible via C# because there's no access to the necessary Zennoposter objects.

I'm using this JavaScript workaround now, which should work well enough in most cases:

Код:
function post_to_url(path, params) {
    var form = document.createElement("form");
    form.setAttribute("method", "post");
    form.setAttribute("action", path);

    for(var key in params) {
        if(params.hasOwnProperty(key)) {
            var hiddenField = document.createElement("input");
            hiddenField.setAttribute("type", "hidden");
            hiddenField.setAttribute("name", key);
            hiddenField.setAttribute("value", params[key]);

            form.appendChild(hiddenField);
         }
    }

    document.body.appendChild(form);
    form.submit();
	
    return true;
}
Maybe this will help others as well. I hope the developers of Zennoposter will integrate cookie handling in POST requests soon.
 
  • Спасибо
Реакции: work4seo

traumatic

Client
Регистрация
22.10.2012
Сообщения
10
Благодарностей
1
Баллы
0
Oh damnit... this SHOULD work ( it worked succesfully in Firefox's webconsole) but DOES NOT work from within Zennoposter. :(
Sorry. Does anyone have any other ideas? Really feeling hopeless here.
 

traumatic

Client
Регистрация
22.10.2012
Сообщения
10
Благодарностей
1
Баллы
0
Ok I can't even output a simple alert() - am I missing something? Does using JS in Zennoposter work at all (except for simple operations)??
 

traumatic

Client
Регистрация
22.10.2012
Сообщения
10
Благодарностей
1
Баллы
0
Solution using C#

I manipulated the DOM in C# now and what can I say... IT WORKS!

Here's a short example:
Код:
// get variables from project
string vURL 	= project.Variables["vMyURL"].Value;
string vValue	= project.Variables["vValueToPost"].Value;

// init
Tab tab = instance.ActiveTab;
Document doc = tab.MainDocument;

// setup form
HtmlElement myForm = doc.CreateElement("form");
myForm.SetAttribute("id", "myPostForm");
myForm.SetAttribute("method", "post");
myForm.SetAttribute("action", vURL);

HtmlElement hiddenField1 = doc.CreateElement("input");
hiddenField1.SetAttribute("type", "hidden");
hiddenField1.SetAttribute("name", "whatever");
hiddenField1.SetAttribute("value", vValue);

HtmlElement myButton = doc.CreateElement("input");
myButton.SetAttribute("type", "submit");
myButton.SetAttribute("id", "MyPostButton");

// manipulate dom
doc.Body.AppendChild(myForm);
doc.FindElementById("myPostForm").AppendChild(hiddenField1);
doc.FindElementById("myPostForm").AppendChild(myButton);

// click submit button
doc.FindElementById("MyPostButton").Click();
if (tab.IsBusy) tab.WaitDownloading();
Dear developer(s) of Zennoposter: Please add support for cookies in POST requests and check if JS is fully supported right now.
It's really akward to handle stuff like this. It works, but it's a pain. Thank you.
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)