这是Json代码
{"data":{"user":{"first_name":"xx","last_name":"xx","email":"xx","countryOfResidence":"GB","country":"LK","nationality":"LK"},"billing_address":{"line1":"xx","city":"xx","postal_code":"xx","country":"LK"},"shipping_address":{"first_name":"xx","last_name":"xx","line1":"xx","city":"xx","postal_code":"xx","country":"LK"},"phone":{"type":"Mobile","number":"xx","countryCode":"94"},"marketing_optin":true,"shipping_address_validation":false,"poma_flow":false,"prox_flow":false,"testParams":{},"content_identifier":"LK:en:2.0.287:signupTerms.signupC","card":{"type":"MASTERCARD","number":"xx","security_code":"xx","expiry_month":"xx","expiry_year":"xx"},"skipInitiateAuth":true},"meta":{"token":"xx","calc":"xx","csci":"xx","locale":{"country":"LK","language":"en"},"state":"ui_checkout_guest","app_name":"xoonboardingnodeweb"}}
这是我希望以正确的方式编写代码并使其工作的PHP代码。 我想知道我的错在哪里。任何人都可以更正此文件吗? 请清楚地帮助这个例子。
$link = "https://www.paypal.com/webscr?cmd=_express-checkout&token=EC-7Y207450BE832821N#/checkout/guest";
$post = "";
$s = _curl($link, json_encode($post), $cookie);
$post = json_encode($array);
$array = json_decode($json_string, true);
$link = "https://www.paypal.com/webapps/xoonboarding/api/onboard/guest";
$post = [
'data' => [
'user' => [
'first_name' => 'xx',
'last_name' => 'xx',
'email' => 'xx',
'countryOfResidence' => 'GB',
'country' => 'LK',
'nationality' => 'lk',
],
'billing_address' => [
'line1' => 'xx',
'city' => 'xx',
'postal_code' => 'xx',
'country' => 'lk',
],
'shipping_address' => [
'first_name' => 'xx',
'last_name' => 'xx',
'line1' => 'xx',
'city' => 'xx',
'postal_code' => 'xx',
'country' => 'lk',
],
'phone' => [
'type' => 'Mobile',
'number' => 'xx',
'countryCode' => '94',
],
'marketing_optin' => true,
'shipping_address_validation' => false,
'poma_flow' => false,
'prox_flow' => false,
'testParams' => [],
'content_identifier' => "LK:en:2.0.287:signupTerms.signupC",
'card' => [
'type' => 'xx',
'number' => xx,
'security_code' => xx,
'expiry_month' => xx,
'expiry_year' => xx,
],
'skipInitiateAuth' => true
],
'meta' => [
'token' => xx,
'calc' => xx,
'csci' => xx,
'locale' => [
'country' => 'LK',
'language' => 'en',
],
'state' => 'ui_checkout_guest',
'app_name' => 'xoonboardingnodeweb',
]
];
$s = _curl($link, json_encode($post), $cookie);
答案 0 :(得分:0)
您可以使用JSON Formatter轻松可视化JSON的结构,并将其转换为PHP。或者您可以创建一个PHP变量,这要归功于<iframe src="https://www.w3schools.com" width="80%" height="380px" scrolling="yes">
和您在示例中给出的JSON代码。
json_decode
&#13;