I am developing an application to download some apps. But I can't cross the Google Play store authentication. So I just know the apps name and download from third party website.
I try to use get_file_content
and curl
, but I get a error response:
The Response content must be a string or object implementing __toString(), "boolean" given.
My code:
private function download_file($name) {
$url='https://apkpure.com/snake-off-more-play-more-fun/com.wepie.snakeoff/download?from=details',
$app_name = $name.'.apk';
$path = self::DOWNLOAD_DIR;
set_time_limit ( 0 );
$url = trim ( $url );
$curl = curl_init ();
curl_setopt ( $curl, CURLOPT_URL, $url );
curl_setopt ( $curl, CURLOPT_HEADER, 0 );
curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, 1 );
$file = curl_exec ( $curl );
curl_close ( $curl );
$filename = $path . $app_name;
$write = @fopen ( $filename, "w" );
if ($write == false) {
return false;
}
if (fwrite ( $write, $file ) == false) {
return false;
}
if (fclose ( $write ) == false) {
return false;
}
return $app_name;
}