Page 1 of 1

Use Mechanize to submit new entry

Posted: Wed Jun 17, 2009 5:11 pm
by glkc
Hi,

When I try to use WWW::Mechanize to submit a new entry to the s9y blog, I see there are two unnamed submit options,
<NONAME>=- Preview - (submit)
<NONAME>=- Save - (submit)

and function submit() doesn't work.

Is there any way to name the submit buttons so Mechanize may work? Thanks,

--George

Re: Use Mechanize to submit new entry

Posted: Wed Jun 17, 2009 5:41 pm
by garvinhicking
Hi!

I don't know WWW:Mechanize. But in javascript, you would simply do a document.getElementById('serendipityEntry').submit().

Regards,
Garvin

Re: Use Mechanize to submit new entry

Posted: Thu Jul 02, 2009 9:24 pm
by glkc
My test seems half working now.

I can see an entry was on database in table serendipity_entries, but It doesn't display on the weblog. Where should I check? Thanks,

Re: Use Mechanize to submit new entry

Posted: Fri Jul 03, 2009 8:14 am
by garvinhicking
Hi!

How does the SQL dump for that entry look like? Maybe some fields are wrong like "isdraft" or "timestamp"?

Regards,
Garvin

Re: Use Mechanize to submit new entry

Posted: Tue Jul 07, 2009 3:07 pm
by glkc
Hi

Thank you Garvin. Following is an output from the entries:

mysql> select * from serendipity_entries where id=27989 or id=27988;
+-------+-------------------------------+------------+-------------------------------+----------+------------+----------+--------+----------------+----------+---------+----------------+---------------+-------------------+
| id | title | timestamp | body | comments | trackbacks | extended | exflag | author | authorid | isdraft | allow_comments | last_modified | moderate_comments |
+-------+-------------------------------+------------+-------------------------------+----------+------------+----------+--------+----------------+----------+---------+----------------+---------------+-------------------+
| 27988 | This is a test. please ignore | 1246558600 | This is a test. please ignore | 0 | 0 | | 0 | first.user | 112 | false | true | 1246558600 | false |
| 27989 | 18z frzlvls done | 1246559730 | | 0 | 0 | | 0 | second.user | 78 | false | false | 1246559730 | false |
+-------+-------------------------------+------------+-------------------------------+----------+------------+----------+--------+----------------+----------+---------+----------------+---------------+-------------------+
2 rows in set (0.00 sec)

Where id=27988, which is entered from an automatic script, is not displayed on the weblog;
id=27989, which is entered from web interface, is displayed.

Thank you.

--George

Re: Use Mechanize to submit new entry

Posted: Tue Jul 07, 2009 3:36 pm
by garvinhicking
Hi!

Is the entry displayed within the backend? The only thing that seems to differ is the "exflag" column, which shouldn't make a difference.

If you use the same authorids, does that make a difference?

Also, check the serendipity_entrycat and serendipity_entryproperties DB tables, if they differ a lot from what they have on their entry_id relations? And you might want to check the _permalinks DB table to see if it has reeceveid an entry.

Regards,
Garvin

Re: Use Mechanize to submit new entry

Posted: Wed Jul 08, 2009 5:26 pm
by glkc
There is no entryid for 27988 on the _entrycat DB tables, but everything looks normal on the _entryproperties and _permalinks DB tables.

mysql> select * from serendipity_entrycat where entryid=27989 or entryid=27988;
+---------+------------+
| entryid | categoryid |
+---------+------------+
| 27989 | 1 |
+---------+------------+
1 row in set (0.00 sec)

Thanks.

Re: Use Mechanize to submit new entry

Posted: Wed Jul 08, 2009 6:12 pm
by garvinhicking
Hi!

Did you maybe try to add a entryid=27989, category=1 entry inside the database? Which s9y version are you using and which plugins? Usually entries without a category should be displayed, but if you use the categorytemplates or startcat plugin for example, those could set a fixed category and this leads to your entry not being displayed.

Also, did you read my questiona bout whether the entry is displayed in the backend?

Re: Use Mechanize to submit new entry

Posted: Wed Jul 08, 2009 6:33 pm
by glkc
That's a quick reply. I'll test the add entryid first.
Also in the form, there is a variable like this
serendipity[categories][]=<UNDEF> (option) [*<UNDEF>/off|16/Announcements]

I entered it like
serendipity[categories][]=16 (option) [<UNDEF>/off|*16/Announcements]

It seems no help.

For the backend question, do you refer to a different thread in the forum or just in this thread?

Thanks a lot.

Re: Use Mechanize to submit new entry

Posted: Wed Jul 08, 2009 6:47 pm
by glkc
The entry was displayed after the entryid was added into *entrycat. Thanks

Also, the s9y version is very old. It is 1.0.1. How do I check the plugins? Thanks

Re: Use Mechanize to submit new entry

Posted: Wed Jul 08, 2009 7:02 pm
by garvinhicking
Hi!

Hm, sadly I don't know how to specify things in mechanize; but the HTTP POST var needs to be serendipity[categories][]=16, yes. Then it should create a entrycat id for "16".

With backend I mean, when you go to the s9y admin panel > Edit entries, do you see the created entry?

Regards,
Garvin

Re: Use Mechanize to submit new entry

Posted: Wed Jul 08, 2009 7:09 pm
by glkc
Yes. They are there. Also, I can find them from quick search. Thanks

Re: Use Mechanize to submit new entry

Posted: Wed Jul 08, 2009 7:29 pm
by garvinhicking
Hi!

Oh, okay. s9y 1.0.1 is VERY VERY old, you should really try to upgraed; the HTTP POST issues could very much likely be associated.

1.0. is about 3 years old...

Regards,
Garvin

Re: Use Mechanize to submit new entry

Posted: Wed Jul 08, 2009 7:40 pm
by glkc
Hi Garvin,

Thanks for your helps. Finally I think it is working. I didn't put a "=" after field("serendipity[categories][]" and that caused problems.

$mech->field("serendipity[body]", "This is a test. please ignore" );
#$mech->field("serendipity[categories][]", "13" ); This line doesn't work
$mech->field("serendipity[categories][]=", 13); This line works

Although the dump form shows same result, i.e.,

serendipity[categories][]=13 (option) [<UNDEF>/off|*13]


Thank you again for your help.

--George