On my site I have some texts with button below so that user can post that text directly as their facebook status I use Form POST request to post that status to my fbapp.

Problem is when user first time use this feature then Apps Request for permission window appears after user ALLOW it then my fbapp page appears which is set in FORM action and the text which I sent via POST gets posted to that page as NULL value

but when user again use this feature(i.e. permission window dnt appear) it directly goes to my fbapp page text succesfully posted as status.

If user already granted permission to App & Use this feature 2nd time then Apps Request for permission window dnt appear text status is posted as $_POST['mystatus'] and updated successfully on user id.

Problem is only when Apps Request for permission window appears after user allow the application then $_POST['mystatus'] dnt get value and status is updated as NULL on user id.

pls HELP how to solve this.

IF USER DISALLOW OR REMOVE APP.
also I want to know How can I show Error Message on page If User dnt Allow Application Request.
& if once used later remove the application then page shows this error:

@donutdan4114 thanks I nevr used that function before can u pls show some example how to use this. My problem here is facebook page of application approval & when user allow my application then facebook redirect back to my script page & all my form post variables lost in this redirect. If user already approved my app. & execute this script 2nd time then can successfully post on wall.
–
VehladSep 20 '12 at 15:04

1 Answer
1

Problem is only when Apps Request for permission window appears after user allow the application then $_POST['mystatus'] dnt get value and status is updated as NULL on user id.

Of course there is no value in $_POST['mystatus'] – because the request that send this parameter is a thing of the past already.

Here’s what happens:

User posts the form contents to your server. In handling that request and that request only, you have access to this data via $_POST.

But the user is not logged in, so you redirect them to the Auth dialog. That means, your scripts execution ends at this point, and the client (browser) makes another request. This request goes to Facebook, and after successful login, the client is redirected again, back to your app’s server.

This last redirect results in another request (and a GET request, to be exact) to your server by the client. It has nothing to do whatsoever with the first POST request your app received – there is absolutely no connection between them. And so of course, you do not have access to the data that was POSTed to your app long time ago in a completely different request.

These are basics of using HTTP, that you should make yourself familiar with if you want to develop web applications. HTTP is a “stateless” protocol – please look up what that actually means!

Now that we’ve covered these basics, for the solution:

One way of introducing a way of “recognizing” requests by the same client that have some logical connection to each other in the stateless protocol HTTP is using a mechanism called “Sessions”. (I don’t want to go into theoretical details here – but PHP has an easy to use session mechanism; if you are not familiar with that, please read up on that as well.)

So, what you can do, is put the data you received via POST in the first request into the session, and store it there for later retrieval.

Then, if the user is not already logged in, you redirect them to the Auth dialog. And once the user “comes back” from there, you check your session and see, “ah, there’s still some data that I’ve received some time earlier with another request, that hasn’t been processed yet” – and then you do exactly that, process it: Retrieve the status message from the session, post it to Facebook, and delete it from the session afterwards (so you won’t process it again on next page load).