in reply to Media Wiki API 'WrongToken'

From the docs:

Important Note

"You need to send the cookie obtained in the login phase when you call the api with the "tokens" action"

Take a look at the REST::Client documentation, specifically the useragent option in the constructor.