How to get Shopify file data in PHP?

To do this we need the main theme ID, so foremost let’s get the theme ID in step 1.

Step 1 Get the theme ID, for that use the below code.
$requests = $_GET;

$hmac = $_GET['hmac'];

$serializeArray = serialize($requests);

$requests = array_diff_key($requests, array('hmac' => ''));

ksort($requests);

$token ="Set your token here";

$shop = "Set your shop name here";

$url = parse_url( 'https://' . $shop );
$host = explode('.', $url['host'] );
$shop  = $host[0];


$theme = shopify_call_shop($token, $shop, "/admin/api/2020-04/themes.json", array(), 'GET');
$theme = json_decode($theme['response'], JSON_PRETTY_PRINT);

  print_r($theme);
By the above code you get the all themes detail, but we have to only need the main theme ID, so let’s add some more code.

$attr = array();
foreach($theme as $cur_theme) {
  foreach ($cur_theme as $key => $value) {
    if($value['role'] === 'main') {
      $theme_id  =  $value['id']; 
Now in the variable $theme_id you have main theme ID. Now final step of our code, below code will give you the whole data of main-product.liquid file, Similarly you can get any file data from Shopify as you need.
$asset_file = array(
        "asset" => array(
                  "key" => "sections/main-product.liquid"                 
                )
      );

      $asset = shopify_call_shop($token, $shop, "/admin/api/2020-04/themes/" . $theme_id .  "/assets.json", $asset_file, 'GET');
      $asset = json_decode($asset['response'], JSON_PRETTY_PRINT);

$FileData ='';
      foreach($asset as $key){
        $FileData  = $key['value'];
      }
Now, all the data of your main-product.liquid file is inside the variable named $FileData.