WordPress transient not working with WP Engine

So I don’t know why the return $cached_result; in the else, but if that’s intentional, then you should probably do:

return json_decode( $cached_result, true );

Because you’re caching the response body (which is a JSON string) and you’re reading the non-cached result like so: $array = json_decode($result, true);.

But if that return was a mistake, then this part:

<?php else: ?>
    <?php return $cached_result; ?>
<?php endif; ?>

Should be written as:

<?php else: ?>
    <?php $array = json_decode( $cached_result, true ); ?>
<?php endif; ?>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)