Decode received URL

Asked

Viewed 42 times

0

I’m working on integrating payments through Pagar.me, but I’m not able to decode their postback to process the returned information.

The return format is based on URL, I performed a url_decode() to better treat the information, in the end it gets like this:

id=000000&fingerprint=0000000000&event=transaction_status_changed&old_status=processing&desired_status=paid&current_status=refused&object=transaction&transaction[object]=transaction....

My problem is in being able to use this information to perform the required validation, I would need to get the information from the field fingerprint and some others, but I’m not getting how I can accomplish this action.

I thought I’d try an array or something like that, but I wasn’t very successful.

I hope you can help me.

  • 1

    Have you tried the parse_str?

  • @Woss, not yet, I will search the doc to use it and see if I can. Thanks for the suggestion.

  • @Woss, it worked, I managed to manipulate. Thank you!!

1 answer

1


Hello, try using parse_str. Example

<?php
$str = "first=value&arr[]=foo+bar&arr[]=baz";
parse_str($str);
echo $first;  // value
echo $arr[0]; // foo bar
echo $arr[1]; // baz

parse_str($str, $output);
echo $output['first'];  // value
echo $output['arr'][0]; // foo bar
echo $output['arr'][1]; // baz

?>
  • Thanks for the help João, I was messing with Woss' tip that was the parse_str also and it worked. Anyway, thanks for your help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.