php - file_get_contents adding extra /\ slashes -
i'm tesitng callback , it's adding unnecessary slashes impeding upon api's ability successfuly communicate server. why appending these slashes , how can remedy situation? code below:
<?php $real_secret = 'cantletyousee'; $my_address = '16qvmcfj6eergwquixlqhucbc2bzzdpmfo'; $my_callback_url = 'http://myurlcantseeit.me/gg/blockchain_callback.php?secret=' . $real_secret; $root_url = 'https://blockchain.info/api/receive'; $parameters = 'method=create&callback='. urlencode($my_callback_url) . '&address=' . $my_address; $response = file_get_contents($root_url . '?' . $parameters); var_dump($response); $object = json_decode($response); ?>
the var dump returning: string(203) "{"input_address":"1mtyhcdeq1euiv7pjl58xtjfwtgx3bqqpe","callback_url":"http:\/\/myurlcantseeit.me\/gg\/blockchain_callback.php?secret=cantletyousee","fee_percent":0,"destination":"16qvmcfj6eergwquixlqhucbc2bzzdpmfo"}"
i replaced secret , site's url dummy information keep private - won't make difference.
as can see, should http://myurlcantseeit.me/gg/blockchain_callback.php?secret=cantletyousee, it's adding backslashes everywhere.
why , how can fix this?
\
escape character , won't affect output.
from php escape sequences
the backslash character has several uses. firstly, if followed non-alphanumeric character, takes away special meaning character may have. use of backslash escape character applies both inside , outside character classes.
yes, can add options while using json_encode
, give try, may helps you
json_encode($response, json_unescaped_unicode | json_unescaped_slashes );
Comments
Post a Comment