PHP Laravel (Shopify App) 如何访问 Guzzle response(stdclass) 数据参数
PHP Laravel (Shopify App) how to access Guzzle response(stdclass) data parameters
我正在使用 Laravel 开发 Shopify 应用程序并使用 Osiset/Larave-Shopify 包。
目前我正在尝试访问来自 Shopify Webhooks 的响应并将 returns 数据打包到 stdclass 对象中。
只是我想从 PHP 中的以下响应对象访问电子邮件,谁能告诉我该怎么做?
提前致谢!
这是响应代码:
stdClass::__set_state(array(
'id' => 2222178795622,
'email' => 'jmmkaler@gmail.com',
'closed_at' => NULL,
'created_at' => '2020-05-09T16:39:11-04:00',
'updated_at' => '2020-05-09T16:39:12-04:00',
'number' => 3,
'note' => NULL,
'token' => '7d485aee4f64562e98444fa11a0acb9d',
'gateway' => 'bogus',
'test' => true,
'total_price' => '590.00',
'subtotal_price' => '500.00',
'total_weight' => 0,
'total_tax' => '90.00',
'taxes_included' => false,
'currency' => 'INR',
'financial_status' => 'paid',
'confirmed' => true,
'total_discounts' => '0.00',
'total_line_items_price' => '500.00',
'cart_token' => '',
'buyer_accepts_marketing' => false,
'name' => '#1003',
'referring_site' => 'https://shipment-tracker.myshopify.com/products/jeans-1',
'landing_site' => '/wallets/checkouts.json',
'cancelled_at' => NULL,
'cancel_reason' => NULL,
'total_price_usd' => '7.82',
'checkout_token' => '587a1c76ed68ae90c521de803bb6c9b7',
'reference' => NULL,
'user_id' => NULL,
'location_id' => NULL,
'source_identifier' => NULL,
'source_url' => NULL,
'processed_at' => '2020-05-09T16:39:11-04:00',
'device_id' => NULL,
'phone' => NULL,
'customer_locale' => 'en',
'app_id' => 580111,
'browser_ip' => '117.203.132.178',
'landing_site_ref' => NULL,
'order_number' => 1003,
'discount_applications' =>
array (
),
'discount_codes' =>
array (
),
'note_attributes' =>
array (
),
'payment_gateway_names' =>
array (
0 => 'bogus',
),
'processing_method' => 'direct',
'checkout_id' => 12780937707622,
'source_name' => 'web',
'fulfillment_status' => NULL,
'tax_lines' =>
array (
0 =>
stdClass::__set_state(array(
'price' => '90.00',
'rate' => 0.179999999999999993338661852249060757458209991455078125,
'title' => 'IGST',
'price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '90.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '90.00',
'currency_code' => 'INR',
)),
)),
)),
),
'tags' => '',
'contact_email' => 'jmmkaler@gmail.com',
'order_status_url' => 'https://shipment-tracker.myshopify.com/27247083622/orders/7d485aee4f64562e98444fa11a0acb9d/authenticate?key=4177ec29bf6e0a924cbc981827e0c5c8',
'presentment_currency' => 'INR',
'total_line_items_price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '500.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '500.00',
'currency_code' => 'INR',
)),
)),
'total_discounts_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
)),
'total_shipping_price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
)),
'subtotal_price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '500.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '500.00',
'currency_code' => 'INR',
)),
)),
'total_price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '590.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '590.00',
'currency_code' => 'INR',
)),
)),
'total_tax_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '90.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '90.00',
'currency_code' => 'INR',
)),
)),
'line_items' =>
array (
0 =>
stdClass::__set_state(array(
'id' => 4852532740198,
'variant_id' => 31739432435814,
'title' => 'Jeans',
'quantity' => 1,
'sku' => '',
'variant_title' => '',
'vendor' => 'Nike',
'fulfillment_service' => 'manual',
'product_id' => 4818366496870,
'requires_shipping' => true,
'taxable' => true,
'gift_card' => false,
'name' => 'Jeans',
'variant_inventory_management' => 'shopify',
'properties' =>
array (
),
'product_exists' => true,
'fulfillable_quantity' => 1,
'grams' => 0,
'price' => '500.00',
'total_discount' => '0.00',
'fulfillment_status' => NULL,
'price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '500.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '500.00',
'currency_code' => 'INR',
)),
)),
'total_discount_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
)),
'discount_allocations' =>
array (
),
'duties' =>
array (
),
'admin_graphql_api_id' => 'gid://shopify/LineItem/4852532740198',
'tax_lines' =>
array (
0 =>
stdClass::__set_state(array(
'title' => 'IGST',
'price' => '90.00',
'rate' => 0.179999999999999993338661852249060757458209991455078125,
'price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '90.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '90.00',
'currency_code' => 'INR',
)),
)),
)),
),
'origin_location' =>
stdClass::__set_state(array(
'id' => 1939741409382,
'country_code' => 'IN',
'province_code' => 'PB',
'name' => 'Shipment-tracker',
'address1' => 'Jalandhar',
'address2' => '',
'city' => 'Jalandhar',
'zip' => '144401',
)),
)),
),
'fulfillments' =>
array (
),
'refunds' =>
array (
),
'total_tip_received' => '0.0',
'original_total_duties_set' => NULL,
'current_total_duties_set' => NULL,
'admin_graphql_api_id' => 'gid://shopify/Order/2222178795622',
'shipping_lines' =>
array (
0 =>
stdClass::__set_state(array(
'id' => 1839082045542,
'title' => 'Standard',
'price' => '0.00',
'code' => 'Standard',
'source' => 'shopify',
'phone' => NULL,
'requested_fulfillment_service_id' => NULL,
'delivery_category' => NULL,
'carrier_identifier' => NULL,
'discounted_price' => '0.00',
'price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
)),
'discounted_price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
)),
'discount_allocations' =>
array (
),
'tax_lines' =>
array (
),
)),
),
'billing_address' =>
stdClass::__set_state(array(
'first_name' => 'Jimmy',
'address1' => 'near ravidas mandir,nawashehar road Village Garha',
'phone' => NULL,
'city' => 'PHILLAUR',
'zip' => '144410',
'province' => 'Punjab',
'country' => 'India',
'last_name' => 'Kaler',
'address2' => 'wuhawosu',
'company' => NULL,
'latitude' => NULL,
'longitude' => NULL,
'name' => 'Jimmy Kaler',
'country_code' => 'IN',
'province_code' => 'PB',
)),
'shipping_address' =>
stdClass::__set_state(array(
'first_name' => 'Jimmy',
'address1' => 'near ravidas mandir,nawashehar road Village Garha',
'phone' => NULL,
'city' => 'PHILLAUR',
'zip' => '144410',
'province' => 'Punjab',
'country' => 'India',
'last_name' => 'Kaler',
'address2' => 'wuhawosu',
'company' => NULL,
'latitude' => NULL,
'longitude' => NULL,
'name' => 'Jimmy Kaler',
'country_code' => 'IN',
'province_code' => 'PB',
)),
'client_details' =>
stdClass::__set_state(array(
'browser_ip' => '117.203.132.178',
'accept_language' => 'en-US,en;q=0.9,es;q=0.8',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
'session_hash' => NULL,
'browser_width' => 1349,
'browser_height' => 657,
)),
'payment_details' =>
stdClass::__set_state(array(
'credit_card_bin' => '1',
'avs_result_code' => NULL,
'cvv_result_code' => NULL,
'credit_card_number' => '•••• •••• •••• 1',
'credit_card_company' => 'Bogus',
)),
'customer' =>
stdClass::__set_state(array(
'id' => 3003356774502,
'email' => 'jmmkaler@gmail.com',
'accepts_marketing' => true,
'created_at' => '2020-04-24T17:09:53-04:00',
'updated_at' => '2020-05-09T16:39:11-04:00',
'first_name' => 'Jimmy',
'last_name' => 'Kaler',
'orders_count' => 0,
'state' => 'disabled',
'total_spent' => '0.00',
'last_order_id' => NULL,
'note' => NULL,
'verified_email' => true,
'multipass_identifier' => NULL,
'tax_exempt' => false,
'phone' => NULL,
'tags' => 'password page, prospect',
'last_order_name' => NULL,
'currency' => 'INR',
'accepts_marketing_updated_at' => '2020-04-24T17:09:53-04:00',
'marketing_opt_in_level' => 'single_opt_in',
'admin_graphql_api_id' => 'gid://shopify/Customer/3003356774502',
'default_address' =>
stdClass::__set_state(array(
'id' => 3312853745766,
'customer_id' => 3003356774502,
'first_name' => 'Jimmy',
'last_name' => 'Kaler',
'company' => NULL,
'address1' => 'near ravidas mandir,nawashehar road Village Garha',
'address2' => 'wuhawosu',
'city' => 'PHILLAUR',
'province' => 'Punjab',
'country' => 'India',
'zip' => '144410',
'phone' => NULL,
'name' => 'Jimmy Kaler',
'province_code' => 'PB',
'country_code' => 'IN',
'country_name' => 'India',
'default' => true,
)),
)),
))
如果以上是实际对象的 var_dump 或 print_r 则执行:
$object->email;
//不同对象User的另一个例子
class User
{
public $name = 'John';
public $age = 34;
private $salary = 4200.00;
protected $identifier = 'ABC';
}
$user = new User();
var_export($user); // outputs string "User::__set_state..."
echo $user->name;
我正在使用 Laravel 开发 Shopify 应用程序并使用 Osiset/Larave-Shopify 包。
目前我正在尝试访问来自 Shopify Webhooks 的响应并将 returns 数据打包到 stdclass 对象中。
只是我想从 PHP 中的以下响应对象访问电子邮件,谁能告诉我该怎么做?
提前致谢!
这是响应代码:
stdClass::__set_state(array(
'id' => 2222178795622,
'email' => 'jmmkaler@gmail.com',
'closed_at' => NULL,
'created_at' => '2020-05-09T16:39:11-04:00',
'updated_at' => '2020-05-09T16:39:12-04:00',
'number' => 3,
'note' => NULL,
'token' => '7d485aee4f64562e98444fa11a0acb9d',
'gateway' => 'bogus',
'test' => true,
'total_price' => '590.00',
'subtotal_price' => '500.00',
'total_weight' => 0,
'total_tax' => '90.00',
'taxes_included' => false,
'currency' => 'INR',
'financial_status' => 'paid',
'confirmed' => true,
'total_discounts' => '0.00',
'total_line_items_price' => '500.00',
'cart_token' => '',
'buyer_accepts_marketing' => false,
'name' => '#1003',
'referring_site' => 'https://shipment-tracker.myshopify.com/products/jeans-1',
'landing_site' => '/wallets/checkouts.json',
'cancelled_at' => NULL,
'cancel_reason' => NULL,
'total_price_usd' => '7.82',
'checkout_token' => '587a1c76ed68ae90c521de803bb6c9b7',
'reference' => NULL,
'user_id' => NULL,
'location_id' => NULL,
'source_identifier' => NULL,
'source_url' => NULL,
'processed_at' => '2020-05-09T16:39:11-04:00',
'device_id' => NULL,
'phone' => NULL,
'customer_locale' => 'en',
'app_id' => 580111,
'browser_ip' => '117.203.132.178',
'landing_site_ref' => NULL,
'order_number' => 1003,
'discount_applications' =>
array (
),
'discount_codes' =>
array (
),
'note_attributes' =>
array (
),
'payment_gateway_names' =>
array (
0 => 'bogus',
),
'processing_method' => 'direct',
'checkout_id' => 12780937707622,
'source_name' => 'web',
'fulfillment_status' => NULL,
'tax_lines' =>
array (
0 =>
stdClass::__set_state(array(
'price' => '90.00',
'rate' => 0.179999999999999993338661852249060757458209991455078125,
'title' => 'IGST',
'price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '90.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '90.00',
'currency_code' => 'INR',
)),
)),
)),
),
'tags' => '',
'contact_email' => 'jmmkaler@gmail.com',
'order_status_url' => 'https://shipment-tracker.myshopify.com/27247083622/orders/7d485aee4f64562e98444fa11a0acb9d/authenticate?key=4177ec29bf6e0a924cbc981827e0c5c8',
'presentment_currency' => 'INR',
'total_line_items_price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '500.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '500.00',
'currency_code' => 'INR',
)),
)),
'total_discounts_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
)),
'total_shipping_price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
)),
'subtotal_price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '500.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '500.00',
'currency_code' => 'INR',
)),
)),
'total_price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '590.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '590.00',
'currency_code' => 'INR',
)),
)),
'total_tax_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '90.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '90.00',
'currency_code' => 'INR',
)),
)),
'line_items' =>
array (
0 =>
stdClass::__set_state(array(
'id' => 4852532740198,
'variant_id' => 31739432435814,
'title' => 'Jeans',
'quantity' => 1,
'sku' => '',
'variant_title' => '',
'vendor' => 'Nike',
'fulfillment_service' => 'manual',
'product_id' => 4818366496870,
'requires_shipping' => true,
'taxable' => true,
'gift_card' => false,
'name' => 'Jeans',
'variant_inventory_management' => 'shopify',
'properties' =>
array (
),
'product_exists' => true,
'fulfillable_quantity' => 1,
'grams' => 0,
'price' => '500.00',
'total_discount' => '0.00',
'fulfillment_status' => NULL,
'price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '500.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '500.00',
'currency_code' => 'INR',
)),
)),
'total_discount_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
)),
'discount_allocations' =>
array (
),
'duties' =>
array (
),
'admin_graphql_api_id' => 'gid://shopify/LineItem/4852532740198',
'tax_lines' =>
array (
0 =>
stdClass::__set_state(array(
'title' => 'IGST',
'price' => '90.00',
'rate' => 0.179999999999999993338661852249060757458209991455078125,
'price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '90.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '90.00',
'currency_code' => 'INR',
)),
)),
)),
),
'origin_location' =>
stdClass::__set_state(array(
'id' => 1939741409382,
'country_code' => 'IN',
'province_code' => 'PB',
'name' => 'Shipment-tracker',
'address1' => 'Jalandhar',
'address2' => '',
'city' => 'Jalandhar',
'zip' => '144401',
)),
)),
),
'fulfillments' =>
array (
),
'refunds' =>
array (
),
'total_tip_received' => '0.0',
'original_total_duties_set' => NULL,
'current_total_duties_set' => NULL,
'admin_graphql_api_id' => 'gid://shopify/Order/2222178795622',
'shipping_lines' =>
array (
0 =>
stdClass::__set_state(array(
'id' => 1839082045542,
'title' => 'Standard',
'price' => '0.00',
'code' => 'Standard',
'source' => 'shopify',
'phone' => NULL,
'requested_fulfillment_service_id' => NULL,
'delivery_category' => NULL,
'carrier_identifier' => NULL,
'discounted_price' => '0.00',
'price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
)),
'discounted_price_set' =>
stdClass::__set_state(array(
'shop_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
'presentment_money' =>
stdClass::__set_state(array(
'amount' => '0.00',
'currency_code' => 'INR',
)),
)),
'discount_allocations' =>
array (
),
'tax_lines' =>
array (
),
)),
),
'billing_address' =>
stdClass::__set_state(array(
'first_name' => 'Jimmy',
'address1' => 'near ravidas mandir,nawashehar road Village Garha',
'phone' => NULL,
'city' => 'PHILLAUR',
'zip' => '144410',
'province' => 'Punjab',
'country' => 'India',
'last_name' => 'Kaler',
'address2' => 'wuhawosu',
'company' => NULL,
'latitude' => NULL,
'longitude' => NULL,
'name' => 'Jimmy Kaler',
'country_code' => 'IN',
'province_code' => 'PB',
)),
'shipping_address' =>
stdClass::__set_state(array(
'first_name' => 'Jimmy',
'address1' => 'near ravidas mandir,nawashehar road Village Garha',
'phone' => NULL,
'city' => 'PHILLAUR',
'zip' => '144410',
'province' => 'Punjab',
'country' => 'India',
'last_name' => 'Kaler',
'address2' => 'wuhawosu',
'company' => NULL,
'latitude' => NULL,
'longitude' => NULL,
'name' => 'Jimmy Kaler',
'country_code' => 'IN',
'province_code' => 'PB',
)),
'client_details' =>
stdClass::__set_state(array(
'browser_ip' => '117.203.132.178',
'accept_language' => 'en-US,en;q=0.9,es;q=0.8',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
'session_hash' => NULL,
'browser_width' => 1349,
'browser_height' => 657,
)),
'payment_details' =>
stdClass::__set_state(array(
'credit_card_bin' => '1',
'avs_result_code' => NULL,
'cvv_result_code' => NULL,
'credit_card_number' => '•••• •••• •••• 1',
'credit_card_company' => 'Bogus',
)),
'customer' =>
stdClass::__set_state(array(
'id' => 3003356774502,
'email' => 'jmmkaler@gmail.com',
'accepts_marketing' => true,
'created_at' => '2020-04-24T17:09:53-04:00',
'updated_at' => '2020-05-09T16:39:11-04:00',
'first_name' => 'Jimmy',
'last_name' => 'Kaler',
'orders_count' => 0,
'state' => 'disabled',
'total_spent' => '0.00',
'last_order_id' => NULL,
'note' => NULL,
'verified_email' => true,
'multipass_identifier' => NULL,
'tax_exempt' => false,
'phone' => NULL,
'tags' => 'password page, prospect',
'last_order_name' => NULL,
'currency' => 'INR',
'accepts_marketing_updated_at' => '2020-04-24T17:09:53-04:00',
'marketing_opt_in_level' => 'single_opt_in',
'admin_graphql_api_id' => 'gid://shopify/Customer/3003356774502',
'default_address' =>
stdClass::__set_state(array(
'id' => 3312853745766,
'customer_id' => 3003356774502,
'first_name' => 'Jimmy',
'last_name' => 'Kaler',
'company' => NULL,
'address1' => 'near ravidas mandir,nawashehar road Village Garha',
'address2' => 'wuhawosu',
'city' => 'PHILLAUR',
'province' => 'Punjab',
'country' => 'India',
'zip' => '144410',
'phone' => NULL,
'name' => 'Jimmy Kaler',
'province_code' => 'PB',
'country_code' => 'IN',
'country_name' => 'India',
'default' => true,
)),
)),
))
如果以上是实际对象的 var_dump 或 print_r 则执行:
$object->email;
//不同对象User的另一个例子
class User
{
public $name = 'John';
public $age = 34;
private $salary = 4200.00;
protected $identifier = 'ABC';
}
$user = new User();
var_export($user); // outputs string "User::__set_state..."
echo $user->name;