Php 调用url并获得响应

Php 调用url并获得响应,php,Php,大家好,我正在尝试调用一个url并从中获取一些json,这就是url https://api.sandbox.blackhawknetwork.com/productCatalogManagement/v1/productCatalogs 你能帮我吗 定义你的 这些命令告诉溪流该做什么 开河 使用读取所有响应数据 看起来像这样: $opts = [ 'http' => [ 'header' => [ /* what headers you want */ ], 'm

大家好,我正在尝试调用一个url并从中获取一些json,这就是url

https://api.sandbox.blackhawknetwork.com/productCatalogManagement/v1/productCatalogs
你能帮我吗

  • 定义你的 这些命令告诉溪流该做什么
  • 开河
  • 使用读取所有响应数据
  • 看起来像这样:

    $opts = [ 'http' => [
        'header' => [ /* what headers you want */ ],
        'method' => 'GET'
    ];
    $context = stream_context_create($opts);
    $content = file_get_contents("URL", false, $context);
    

    file\u get\u contents()
    或使用phpp的
    CURL
    ,请查看php.net;像
    file\u get\u contents()
    这样的函数可能会对您有所帮助。