我正在尝试使用 ohmybrew/laravel-shopify 在 Laravel 中以单个 Shopify 资产的形式获取对象:
$asset = $shop->api()->rest('GET', '/admin/api/'.ShopifyApp::api()->getVersion().'/themes/80166092888/assets.json?asset[key]=snippets/collection-grid-item.liquid');
我相信 $asset 的结果应该是 Shopify 资产但是当我 print_r($asset) 我得到这个:
_secure_admin_session_id_csrf=7e198a5093ed7d91cfd87bda81a73126;路径=/管理员;过期=2020 年 3 月 16 日星期一 13:28:09 -0000;安全的; 仅http;SameSite=Lax [3] => _orig_referrer=; 过期=格林威治标准时间 19 年 12 月 30 日星期一 13:28:09;路径=/; HttpOnly [4] => _landing_page=%2Fadmin%2Fauth%2Flogin; 过期=格林威治标准时间 19 年 12 月 30 日星期一 13:28:09;路径=/; HttpOnly [5] => _master_udr=eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJaWszTTJGbVl6VmlaaTA0TlRoa0xUUmtOemN0T0RZNU55MWxZV0l6WVRnM05HVmtObVlHT2daRlJnPT0iLCJleHAiOiIyMDIxLTEyLTE2VDEzOjI4OjA5LjU3OVoiLCJwdXIiOiJjb29raWUuX21hc3Rlcl91ZHIifX0%3D--e71a00abb5d0a41d5af672a647e68b4306ceea78; 域=.myshopify.com;路径=/管理员;到期=2021 年 12 月 16 日星期四 13:28:09 -0000;安全的; HttpOnly ) [X-Sorting-Hat-PodId] => 数组 ( [0] => 87 ) [X-Sorting-Hat-ShopId] => 数组 ( [0] => 8865972324 ) [Vary] => 数组 ( [ 0] =>; 阻止所有混合内容;child-src 'self' https:// shopify-pos:// ; 连接-src 'self' wss:// https://*; 框架祖先“无”;img-src 'self' 数据:blob:https:;script-src https://cdn.shopify.com https://cdn.shopify.cn https://js-agent.newrelic.com https://bam.nr-data.net https://v.shopify .com'unsafe-inline' 'unsafe-eval'; 升级不安全请求;report-uri /csp-report?source%5Baction%5D=login&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fauth&source%5Bsection%5D=admin&source%5Buuid%5D=8f3c44cc-7e32-48f5-a018-80df31681bc9) [X-Content-Type-Options] => Array ([0] => nosniff) [X-Download-Options] => Array ([0] => noopen) [X-Permitted-Cross-Domain-Policies] = > 数组 ( [0] => 无 ) [X-XSS-Protection] => 数组 ( [0] => 1; mode=block; report=/xss-report?source%5Baction%5D=login&source%5Bapp%5D =Shopify&source%5Bcontroller%5D=admin%2Fauth&source%5Bsection%5D=admin&source%5Buuid%5D=8f3c44cc-7e32-48f5-a018-80df31681bc9 ) [X-Dc] => 数组 ([0] => gcp-us-east1 ,gcp-us-central1,gcp-us-central1 ) [NEL] => 数组 ([0] => {"report_to":"https://monorail-edge.shopifycloud.com/v1/reports/nel/20190325/shopify "}]} [1] => {"group":"network-errors","max_age":2592000,"endpoints" :[{"url":" https://monorail-edge.shopifycloud.com/v1/reports/nel/20190325/shopify"}]}) [X-Request-ID] => 数组 ([0] => 8f3c44cc-7e32-48f5-a018-80df31681bc9) [CF-Cache-Status] => 数组 ([0] => DYNAMIC) [ Expect-CT] => 数组 ([0] => max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" ) [服务器] => 数组 ( [0] => cloudflare ) [CF-RAY] => 数组 ( [0] => 5460ffb34d00dc0b-LHR ) ) [headerNames:GuzzleHttp\Psr7\Response:private] => 数组 ( [日期] => Date [content-type] => Content-Type [transfer-encoding] => Transfer-Encoding [connection] => Connection [set-cookie] => Set-Cookie [x-sorting-hat-podid] => X- Sorting-Hat-PodId [x-sorting-hat-shopid] => X-Sorting-Hat-ShopId [vary] => Vary [referrer-policy] => Referrer-Policy [x-frame-options] => X- Frame-Options [x-shopid] => X-ShopId [x-shardid] =>X-ShardId [cache-control] => Cache-Control [x-shopify-login-required] => X-Shopify-Login-Required [shopify-auth-mechanisms] => Shopify-Auth-Mechanisms [strict-transport- security] => Strict-Transport-Security [x-shopify-stage] => X-Shopify-Stage [content-security-policy] => Content-Security-Policy [x-content-type-options] => X- Content-Type-Options [x-download-options] => X-Download-Options [x-permitted-cross-domain-policies] => X-Permitted-Cross-Domain-Policies [x-xss-protection] => X-XSS-Protection [x-dc] => X-Dc [nel] => NEL [report-to] => Report-To [x-request-id] => X-Request-ID [cf-cache- status] => CF-Cache-Status [expect-ct] => Expect-CT [server] => Server [cf-ray] => CF-RAY ) [protocol:GuzzleHttp\Psr7\Response:private] => 1.1 [流:GuzzleHttp\Psr7\Response:private] =>GuzzleHttp\Psr7\Stream 对象 ( [stream:GuzzleHttp\Psr7\Stream:private] => 资源 id #15 [size:GuzzleHttp\Psr7\Stream:private] => [seekable:GuzzleHttp\Psr7\Stream:private] => 1 [可读:GuzzleHttp\Psr7\Stream:private] => 1 [可写:GuzzleHttp\Psr7\Stream:private] => 1 [uri:GuzzleHttp\Psr7\Stream:private] => php://temp [customMetadata: GuzzleHttp\Psr7\Stream:private] => Array ( ) ) [body] => [link] => [timestamps] => Array ( [0] => [1] => 1576502889.2041 )GuzzleHttp\Psr7\Stream:private] => Array ( ) ) [body] => [link] => [timestamps] => Array ( [0] => [1] => 1576502889.2041 )GuzzleHttp\Psr7\Stream:private] => Array ( ) ) [body] => [link] => [timestamps] => Array ( [0] => [1] => 1576502889.2041 )
我可以使用以下方法正确检索所有资产的列表:
$assets = $shop->api()->rest('GET', '/admin/api/'.ShopifyApp::api()->getVersion().'/themes/80166092888/assets.json');
但是这个对象不包括我需要的信息——特别是每项资产的价值。
Shopify 文档详细说明了这是检索单个资产的正确方法:
GET /admin/api/2019-10/themes/#{theme_id}/assets.json?asset[key]=templates/index.liquid&theme_id=828155753
我可以成功地从浏览器发出 GET 请求来检索我想要的信息。
不确定我在 PHP/Laravel/OhMyBrew 方面做错了什么。