PHP receives the data incorrectly when I send it from an IOS device using ionic
I have a problematic issue, I send data from my ionic app running on an android device:
Data send from the app to the backend

I recieve this data on my php backend like this:
Data I recieve in the php backend from an android device

This data is sent and recieved ok, but, I got an issue when I recieve the same data from an ios device, I recieve the data like this:
Data I recieve in the php backend from an ios device

Have you got any solutions to this problem? how can I manage this data? can I transform this data to another format to use it?
Thanks :)
EDIT:
Code in my ionic app:
var camposRequeridos=IDVisita: this.reparto.IDVisita, Expedicion: this.albaranes; //this.albaranes is an array with 1 or more objects
this.communicate.postRecogida(camposRequeridos);
Code in comunicate.ts
export class CommunicateProvider
private defaultHeaders = "Content-Type": "application/json";
constructor(public http:HTTP,
private auth: AuthProvider)
this.http.setDataSerializer('json');
get(URL, params, headers)
let signedHeaders = this.auth.signRequest(headers);
return this.http.get(URL, params, signedHeaders);
post(URL, params, headers)
let signedHeaders = this.auth.signRequest(headers);
return this.http.post(URL, params, signedHeaders);
postRecogida(camposRequeridos)
return this.http.post(SERVER_URL + '/Recogida', camposRequeridos, this.auth.signRequest(this.defaultHeaders));
In the api-call.php in case that the method is post:
case 'POST':
parse_str($var, $POST);
$_POST = array_merge((array)$_POST, (array)$POST);
break;
And in recogida.php i transforn the data if i recieve a string:
if(isset($_POST['Expedicion']))
if(is_string($_POST['Expedicion']))
$expediciones = json_decode($_POST['Expedicion'], true);
else
$expediciones = $_POST['Expedicion'];
else
$expediciones = array();
EDIT:
After a lot of searching I discover that is an ionic bug or something like that because I try to build the app again in ios and on android and the issue dissapear, but sometimes appears again when I build the app again, I dont know why this is happening
php
|
show 3 more comments
I have a problematic issue, I send data from my ionic app running on an android device:
Data send from the app to the backend

I recieve this data on my php backend like this:
Data I recieve in the php backend from an android device

This data is sent and recieved ok, but, I got an issue when I recieve the same data from an ios device, I recieve the data like this:
Data I recieve in the php backend from an ios device

Have you got any solutions to this problem? how can I manage this data? can I transform this data to another format to use it?
Thanks :)
EDIT:
Code in my ionic app:
var camposRequeridos=IDVisita: this.reparto.IDVisita, Expedicion: this.albaranes; //this.albaranes is an array with 1 or more objects
this.communicate.postRecogida(camposRequeridos);
Code in comunicate.ts
export class CommunicateProvider
private defaultHeaders = "Content-Type": "application/json";
constructor(public http:HTTP,
private auth: AuthProvider)
this.http.setDataSerializer('json');
get(URL, params, headers)
let signedHeaders = this.auth.signRequest(headers);
return this.http.get(URL, params, signedHeaders);
post(URL, params, headers)
let signedHeaders = this.auth.signRequest(headers);
return this.http.post(URL, params, signedHeaders);
postRecogida(camposRequeridos)
return this.http.post(SERVER_URL + '/Recogida', camposRequeridos, this.auth.signRequest(this.defaultHeaders));
In the api-call.php in case that the method is post:
case 'POST':
parse_str($var, $POST);
$_POST = array_merge((array)$_POST, (array)$POST);
break;
And in recogida.php i transforn the data if i recieve a string:
if(isset($_POST['Expedicion']))
if(is_string($_POST['Expedicion']))
$expediciones = json_decode($_POST['Expedicion'], true);
else
$expediciones = $_POST['Expedicion'];
else
$expediciones = array();
EDIT:
After a lot of searching I discover that is an ionic bug or something like that because I try to build the app again in ios and on android and the issue dissapear, but sometimes appears again when I build the app again, I dont know why this is happening
php
I suggest you send the data as JSON
– RiggsFolly
Nov 14 '18 at 14:10
Please go read How to Ask. You showing us just a few screenshots of what data supposedly looks like, is not really helpful in figuring out what the problem/cause might be. Show us at least your code that gathers and sends this data.
– misorude
Nov 14 '18 at 14:11
Code is preferred as text not image. Thanks.
– E.Coms
Nov 14 '18 at 14:14
@RiggsFolly I´m sedding it as a JSON already
– David Polo
Nov 14 '18 at 15:37
@misorude I updated the Question fo put some of my code :)
– David Polo
Nov 15 '18 at 7:58
|
show 3 more comments
I have a problematic issue, I send data from my ionic app running on an android device:
Data send from the app to the backend

I recieve this data on my php backend like this:
Data I recieve in the php backend from an android device

This data is sent and recieved ok, but, I got an issue when I recieve the same data from an ios device, I recieve the data like this:
Data I recieve in the php backend from an ios device

Have you got any solutions to this problem? how can I manage this data? can I transform this data to another format to use it?
Thanks :)
EDIT:
Code in my ionic app:
var camposRequeridos=IDVisita: this.reparto.IDVisita, Expedicion: this.albaranes; //this.albaranes is an array with 1 or more objects
this.communicate.postRecogida(camposRequeridos);
Code in comunicate.ts
export class CommunicateProvider
private defaultHeaders = "Content-Type": "application/json";
constructor(public http:HTTP,
private auth: AuthProvider)
this.http.setDataSerializer('json');
get(URL, params, headers)
let signedHeaders = this.auth.signRequest(headers);
return this.http.get(URL, params, signedHeaders);
post(URL, params, headers)
let signedHeaders = this.auth.signRequest(headers);
return this.http.post(URL, params, signedHeaders);
postRecogida(camposRequeridos)
return this.http.post(SERVER_URL + '/Recogida', camposRequeridos, this.auth.signRequest(this.defaultHeaders));
In the api-call.php in case that the method is post:
case 'POST':
parse_str($var, $POST);
$_POST = array_merge((array)$_POST, (array)$POST);
break;
And in recogida.php i transforn the data if i recieve a string:
if(isset($_POST['Expedicion']))
if(is_string($_POST['Expedicion']))
$expediciones = json_decode($_POST['Expedicion'], true);
else
$expediciones = $_POST['Expedicion'];
else
$expediciones = array();
EDIT:
After a lot of searching I discover that is an ionic bug or something like that because I try to build the app again in ios and on android and the issue dissapear, but sometimes appears again when I build the app again, I dont know why this is happening
php
I have a problematic issue, I send data from my ionic app running on an android device:
Data send from the app to the backend

I recieve this data on my php backend like this:
Data I recieve in the php backend from an android device

This data is sent and recieved ok, but, I got an issue when I recieve the same data from an ios device, I recieve the data like this:
Data I recieve in the php backend from an ios device

Have you got any solutions to this problem? how can I manage this data? can I transform this data to another format to use it?
Thanks :)
EDIT:
Code in my ionic app:
var camposRequeridos=IDVisita: this.reparto.IDVisita, Expedicion: this.albaranes; //this.albaranes is an array with 1 or more objects
this.communicate.postRecogida(camposRequeridos);
Code in comunicate.ts
export class CommunicateProvider
private defaultHeaders = "Content-Type": "application/json";
constructor(public http:HTTP,
private auth: AuthProvider)
this.http.setDataSerializer('json');
get(URL, params, headers)
let signedHeaders = this.auth.signRequest(headers);
return this.http.get(URL, params, signedHeaders);
post(URL, params, headers)
let signedHeaders = this.auth.signRequest(headers);
return this.http.post(URL, params, signedHeaders);
postRecogida(camposRequeridos)
return this.http.post(SERVER_URL + '/Recogida', camposRequeridos, this.auth.signRequest(this.defaultHeaders));
In the api-call.php in case that the method is post:
case 'POST':
parse_str($var, $POST);
$_POST = array_merge((array)$_POST, (array)$POST);
break;
And in recogida.php i transforn the data if i recieve a string:
if(isset($_POST['Expedicion']))
if(is_string($_POST['Expedicion']))
$expediciones = json_decode($_POST['Expedicion'], true);
else
$expediciones = $_POST['Expedicion'];
else
$expediciones = array();
EDIT:
After a lot of searching I discover that is an ionic bug or something like that because I try to build the app again in ios and on android and the issue dissapear, but sometimes appears again when I build the app again, I dont know why this is happening
php
php
edited Nov 15 '18 at 13:02
David Polo
asked Nov 14 '18 at 14:04
David PoloDavid Polo
11
11
I suggest you send the data as JSON
– RiggsFolly
Nov 14 '18 at 14:10
Please go read How to Ask. You showing us just a few screenshots of what data supposedly looks like, is not really helpful in figuring out what the problem/cause might be. Show us at least your code that gathers and sends this data.
– misorude
Nov 14 '18 at 14:11
Code is preferred as text not image. Thanks.
– E.Coms
Nov 14 '18 at 14:14
@RiggsFolly I´m sedding it as a JSON already
– David Polo
Nov 14 '18 at 15:37
@misorude I updated the Question fo put some of my code :)
– David Polo
Nov 15 '18 at 7:58
|
show 3 more comments
I suggest you send the data as JSON
– RiggsFolly
Nov 14 '18 at 14:10
Please go read How to Ask. You showing us just a few screenshots of what data supposedly looks like, is not really helpful in figuring out what the problem/cause might be. Show us at least your code that gathers and sends this data.
– misorude
Nov 14 '18 at 14:11
Code is preferred as text not image. Thanks.
– E.Coms
Nov 14 '18 at 14:14
@RiggsFolly I´m sedding it as a JSON already
– David Polo
Nov 14 '18 at 15:37
@misorude I updated the Question fo put some of my code :)
– David Polo
Nov 15 '18 at 7:58
I suggest you send the data as JSON
– RiggsFolly
Nov 14 '18 at 14:10
I suggest you send the data as JSON
– RiggsFolly
Nov 14 '18 at 14:10
Please go read How to Ask. You showing us just a few screenshots of what data supposedly looks like, is not really helpful in figuring out what the problem/cause might be. Show us at least your code that gathers and sends this data.
– misorude
Nov 14 '18 at 14:11
Please go read How to Ask. You showing us just a few screenshots of what data supposedly looks like, is not really helpful in figuring out what the problem/cause might be. Show us at least your code that gathers and sends this data.
– misorude
Nov 14 '18 at 14:11
Code is preferred as text not image. Thanks.
– E.Coms
Nov 14 '18 at 14:14
Code is preferred as text not image. Thanks.
– E.Coms
Nov 14 '18 at 14:14
@RiggsFolly I´m sedding it as a JSON already
– David Polo
Nov 14 '18 at 15:37
@RiggsFolly I´m sedding it as a JSON already
– David Polo
Nov 14 '18 at 15:37
@misorude I updated the Question fo put some of my code :)
– David Polo
Nov 15 '18 at 7:58
@misorude I updated the Question fo put some of my code :)
– David Polo
Nov 15 '18 at 7:58
|
show 3 more comments
1 Answer
1
active
oldest
votes
In order to give a better answer as to why this is happening (and how to "fix it"), the code that originates that data would be needed.
another question relevant to answering this properly is if the iOS data is consistent (always same structure).
That said, what can be done is some simple data management/cleaning;
Create a function that processes the data coming from devices and enforces the arbitrary datastructure you need.
There are multiple ways of doing this, one would be to have a template of the datastructure, and the look for the values recursively in the data received. this would work even if the structure of the data changes, though not if the keys change.
I would advise to do some research before posting a question.
Hi Manuel, thanks for answer, the code that send the data is: var camposRequeridos=IDVisita: this.reparto.IDVisita, Expedicion: this.albaranes; this.communicate.postRecogida(camposRequeridos);
– David Polo
Nov 14 '18 at 15:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302060%2fphp-receives-the-data-incorrectly-when-i-send-it-from-an-ios-device-using-ionic%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In order to give a better answer as to why this is happening (and how to "fix it"), the code that originates that data would be needed.
another question relevant to answering this properly is if the iOS data is consistent (always same structure).
That said, what can be done is some simple data management/cleaning;
Create a function that processes the data coming from devices and enforces the arbitrary datastructure you need.
There are multiple ways of doing this, one would be to have a template of the datastructure, and the look for the values recursively in the data received. this would work even if the structure of the data changes, though not if the keys change.
I would advise to do some research before posting a question.
Hi Manuel, thanks for answer, the code that send the data is: var camposRequeridos=IDVisita: this.reparto.IDVisita, Expedicion: this.albaranes; this.communicate.postRecogida(camposRequeridos);
– David Polo
Nov 14 '18 at 15:15
add a comment |
In order to give a better answer as to why this is happening (and how to "fix it"), the code that originates that data would be needed.
another question relevant to answering this properly is if the iOS data is consistent (always same structure).
That said, what can be done is some simple data management/cleaning;
Create a function that processes the data coming from devices and enforces the arbitrary datastructure you need.
There are multiple ways of doing this, one would be to have a template of the datastructure, and the look for the values recursively in the data received. this would work even if the structure of the data changes, though not if the keys change.
I would advise to do some research before posting a question.
Hi Manuel, thanks for answer, the code that send the data is: var camposRequeridos=IDVisita: this.reparto.IDVisita, Expedicion: this.albaranes; this.communicate.postRecogida(camposRequeridos);
– David Polo
Nov 14 '18 at 15:15
add a comment |
In order to give a better answer as to why this is happening (and how to "fix it"), the code that originates that data would be needed.
another question relevant to answering this properly is if the iOS data is consistent (always same structure).
That said, what can be done is some simple data management/cleaning;
Create a function that processes the data coming from devices and enforces the arbitrary datastructure you need.
There are multiple ways of doing this, one would be to have a template of the datastructure, and the look for the values recursively in the data received. this would work even if the structure of the data changes, though not if the keys change.
I would advise to do some research before posting a question.
In order to give a better answer as to why this is happening (and how to "fix it"), the code that originates that data would be needed.
another question relevant to answering this properly is if the iOS data is consistent (always same structure).
That said, what can be done is some simple data management/cleaning;
Create a function that processes the data coming from devices and enforces the arbitrary datastructure you need.
There are multiple ways of doing this, one would be to have a template of the datastructure, and the look for the values recursively in the data received. this would work even if the structure of the data changes, though not if the keys change.
I would advise to do some research before posting a question.
answered Nov 14 '18 at 14:21
Manuel HerreraManuel Herrera
63
63
Hi Manuel, thanks for answer, the code that send the data is: var camposRequeridos=IDVisita: this.reparto.IDVisita, Expedicion: this.albaranes; this.communicate.postRecogida(camposRequeridos);
– David Polo
Nov 14 '18 at 15:15
add a comment |
Hi Manuel, thanks for answer, the code that send the data is: var camposRequeridos=IDVisita: this.reparto.IDVisita, Expedicion: this.albaranes; this.communicate.postRecogida(camposRequeridos);
– David Polo
Nov 14 '18 at 15:15
Hi Manuel, thanks for answer, the code that send the data is: var camposRequeridos=IDVisita: this.reparto.IDVisita, Expedicion: this.albaranes; this.communicate.postRecogida(camposRequeridos);
– David Polo
Nov 14 '18 at 15:15
Hi Manuel, thanks for answer, the code that send the data is: var camposRequeridos=IDVisita: this.reparto.IDVisita, Expedicion: this.albaranes; this.communicate.postRecogida(camposRequeridos);
– David Polo
Nov 14 '18 at 15:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302060%2fphp-receives-the-data-incorrectly-when-i-send-it-from-an-ios-device-using-ionic%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I suggest you send the data as JSON
– RiggsFolly
Nov 14 '18 at 14:10
Please go read How to Ask. You showing us just a few screenshots of what data supposedly looks like, is not really helpful in figuring out what the problem/cause might be. Show us at least your code that gathers and sends this data.
– misorude
Nov 14 '18 at 14:11
Code is preferred as text not image. Thanks.
– E.Coms
Nov 14 '18 at 14:14
@RiggsFolly I´m sedding it as a JSON already
– David Polo
Nov 14 '18 at 15:37
@misorude I updated the Question fo put some of my code :)
– David Polo
Nov 15 '18 at 7:58