PHP receives the data incorrectly when I send it from an IOS device using ionic










-1















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



enter image description here



I recieve this data on my php backend like this:



Data I recieve in the php backend from an android device



enter image description here



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



enter image description here



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










share|improve this question
























  • 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















-1















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



enter image description here



I recieve this data on my php backend like this:



Data I recieve in the php backend from an android device



enter image description here



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



enter image description here



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










share|improve this question
























  • 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













-1












-1








-1


0






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



enter image description here



I recieve this data on my php backend like this:



Data I recieve in the php backend from an android device



enter image description here



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



enter image description here



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










share|improve this question
















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



enter image description here



I recieve this data on my php backend like this:



Data I recieve in the php backend from an android device



enter image description here



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



enter image description here



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 android ios ionic-framework ionic3






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












1 Answer
1






active

oldest

votes


















0














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.






share|improve this answer























  • 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











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
);



);













draft saved

draft discarded


















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









0














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.






share|improve this answer























  • 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
















0














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.






share|improve this answer























  • 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














0












0








0







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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




















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

What does pagestruct do in Eviews?

Dutch intervention in Lombok and Karangasem

Channel Islands