When I post from a form I have no trouble having action=edit work.
But when I send the same $postdata through a curl script I get: error code="badtoken".
<? $qstr=file_get_contents("php://input");
$url = "http://localhost:8888/hosted/hum211/api.php?action=edit"; $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL,$url); // set url to post to curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s curl_setopt($ch, CURLOPT_POST, 1); // set POST method curl_setopt($ch, CURLOPT_POSTFIELDS, $qstr); // add POST fields $result = curl_exec($ch); // run the whole process curl_close($ch); echo $result; ?>
To check I tried sending both not to api.php but to some php that would just display the postfilelds. They look exactly alike.
Not sure what to do next.
Timothy S. McKenna Humanities teacher Parkway Academy of Technology and Health, a Boston Public High School 1205 VFW Parkway, Boston, MA 02132 rm404 tim@sitebuilt.net, http://sitebuilt.net exp. course news on twitter, id: mrtmckenna class wiki sites: http://pathboston.com/hum3 Humanities 3 http://pathboston.com/hum2 Humanities 2 (617) 942-0103
On Tue, Dec 14, 2010 at 3:00 AM, Tim McKenna mckenna.tim@gmail.com wrote:
When I post from a form I have no trouble having action=edit work.
But when I send the same $postdata through a curl script I get: error code="badtoken".
Do you login using curl? Do you send the edit token?
I login manually, send a query to get the edit token(not using curl) and then put that token in the postfields.
I have a http form version that works and makes the edits. The postvar string of that version looks exactly like what comes out of the curl version.
On Tue, Dec 14, 2010 at 2:59 AM, Bryan Tong Minh bryan.tongminh@gmail.comwrote:
On Tue, Dec 14, 2010 at 3:00 AM, Tim McKenna mckenna.tim@gmail.com wrote:
When I post from a form I have no trouble having action=edit work.
But when I send the same $postdata through a curl script I get: error code="badtoken".
Do you login using curl? Do you send the edit token?
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
2010/12/14 Tim McKenna tim@sitebuilt.net:
I login manually, send a query to get the edit token(not using curl) and then put that token in the postfields.
I have a http form version that works and makes the edits. The postvar string of that version looks exactly like what comes out of the curl version.
Do you also pass the login cookie back to the edit token request AND the action=edit request?
Roan Kattouw (Catrope)
No I don't do anything with cookies. Thanks for the tip. I will look into that, I'm not sure what it is.
On Tue, Dec 14, 2010 at 8:03 AM, Roan Kattouw roan.kattouw@gmail.comwrote:
2010/12/14 Tim McKenna tim@sitebuilt.net:
I login manually, send a query to get the edit token(not using curl) and then put that token in the postfields.
I have a http form version that works and makes the edits. The postvar string of that version looks exactly like what comes out of the curl version.
Do you also pass the login cookie back to the edit token request AND the action=edit request?
Roan Kattouw (Catrope)
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
mediawiki-api@lists.wikimedia.org