Getting OAuth exception, Graph API

Hey,

Since the old version of my application suddenly not working anymore cause permissions (old rest api), I want to update the application and use the graph API.

The application's task is to create events on behalf of a user, pages on facebook.

So my idea to manage it:

1) get the "code" by referring the user to this page:
Http://www.facebook.com/dialog/oauth?client_id=__ID__&redirect_uri=__URL__&scope=offline_access,create_event,photo_upload

Then get the code, storing it in a database. Since I get permission I can create an event offline_access for later.

2) get the access token by running the following code:

But here is broken. You can get 400, this message:

{
The ' error ': {
"Type": "OAuthException"
"Message": "authentication error in the validation code.
}
}

I have no idea what went wrong. Can u help me please?

Thanks, Fdot

(P.S. step 3 is posting on Facebook)