Thread:Project:Support desk/badtoken problem calling the API with action=edit

I´m trying to write an extension(specialpage) that creates a new wikipage containing the data from a webform filled by a user.

This works good for Anonymous Users(for the testsystem anonymous editing is allowed). If a user is logged in whether local or LDAP-account I get badtoken errors.

My API-call looks like this: "~/api.php?action=edit&title=".$title."&text=".$text."&format=php&token=".$token;"

I fetch the edit-token via "urlencode($wgUser->getEditToken)" and it looks the same like in "~api.php?action=tokens"...

What am I missing here?