R
R
rejjer2016-09-22 18:17:19
Angular
rejjer, 2016-09-22 18:17:19

Restangular + PHP how to accept data on the server?

This is how I send:

var auth= {
  user: 'username',
  pass: 'password',
}
Restangular.all('api').post(auth);

I accept:
$mytext="\n=====================\n";
$mytext .= "POST: \n";
foreach ($_POST as $key => $value) {
  $mytext .= $key ." = ". $value ."\n";
}
$mytext .= "\n=====================\n";
$fp = fopen('log.txt', 'at');
fwrite($fp, $mytext);
fclose($fp);

And the file is empty:
=====================
POST: 

=====================

What's wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan, 2016-09-22
@0neS

var_dump($_REQUEST);Show

A
Anton, 2016-09-22
@sHinE

Then show print_r(file_get_contents('php://input'));
And in general even better in the developer tools or a firebug in network requests, see what goes to your server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question