@@ -6,7 +6,8 @@ class Aliyundrive {
66
77 function __construct ($ tag ) {
88 $ this ->disktag = $ tag ;
9- $ this ->auth_url = 'https://websv.aliyundrive.com/token/refresh ' ;
9+ //$this->auth_url = 'https://websv.aliyundrive.com/token/refresh';
10+ $ this ->auth_url = 'https://auth.aliyundrive.com/v2/account/token ' ;
1011 $ this ->api_url = 'https://api.aliyundrive.com/v2 ' ;
1112 $ this ->driveId = getConfig ('driveId ' , $ tag );
1213 $ res = $ this ->get_access_token (getConfig ('refresh_token ' , $ tag ));
@@ -121,7 +122,9 @@ protected function list_path($path = '/')
121122 if ($ files ['type ' ]=='file ' ) {
122123 if (in_array (splitlast ($ files ['name ' ],'. ' )[1 ], $ exts ['txt ' ])) {
123124 if (!(isset ($ files ['content ' ])&&$ files ['content ' ]['stat ' ]==200 )) {
124- $ content1 = curl ('GET ' , $ files ['download_url ' ]);
125+ $ header ['Referer ' ] = 'https://www.aliyundrive.com/ ' ;
126+ $ header ['User-Agent ' ] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36 ' ;
127+ $ content1 = curl ('GET ' , $ files ['download_url ' ], '' , $ header );
125128 $ files ['content ' ] = $ content1 ;
126129 savecache ('path_ ' . $ path , $ files , $ this ->disktag );
127130 }
@@ -130,7 +133,7 @@ protected function list_path($path = '/')
130133 }
131134 if (!$ files ) {
132135 $ files ['error ' ]['code ' ] = 'Not Found ' ;
133- $ files ['error ' ]['message ' ] = ' Not Found ' ;
136+ $ files ['error ' ]['message ' ] = $ path . ' Not Found ' ;
134137 $ files ['error ' ]['stat ' ] = 404 ;
135138 } elseif (isset ($ files ['stat ' ])) {
136139 $ files ['error ' ]['stat ' ] = $ files ['stat ' ];
@@ -612,7 +615,7 @@ public function AddDisk() {
612615 if (isset ($ _GET ['SelectDrive ' ])) {
613616 if ($ this ->access_token == '' ) {
614617 if (isset ($ _POST ['refresh_token ' ])) {
615- $ res = curl ('POST ' , $ this ->auth_url , json_encode ([ 'refresh_token ' => $ _POST ['refresh_token ' ] ]), ["content-type " =>"application/json; charset=utf-8 " ]);
618+ $ res = curl ('POST ' , $ this ->auth_url , json_encode ([ 'refresh_token ' => $ _POST ['refresh_token ' ], ' grant_type ' => ' refresh_token ' ]), ["content-type " =>"application/json; charset=utf-8 " ]);
616619 //return output($res['body']);
617620 if ($ res ['stat ' ]!=200 ) {
618621 return message ($ res ['body ' ], $ res ['stat ' ], $ res ['stat ' ]);
@@ -645,7 +648,7 @@ public function AddDisk() {
645648 }
646649 }
647650 if (!isset ($ result ['default_drive_id ' ])) {
648- $ res = curl ('POST ' , $ this ->auth_url , json_encode ([ 'refresh_token ' => getConfig ('refresh_token ' , $ this ->disktag ) ]), ["content-type " =>"application/json; charset=utf-8 " ]);
651+ $ res = curl ('POST ' , $ this ->auth_url , json_encode ([ 'refresh_token ' => getConfig ('refresh_token ' , $ this ->disktag ), ' grant_type ' => ' refresh_token ' ]), ["content-type " =>"application/json; charset=utf-8 " ]);
649652 //return output($res['body']);
650653 if ($ res ['stat ' ]!=200 ) {
651654 return message ($ res ['body ' ], $ res ['stat ' ], $ res ['stat ' ]);
@@ -789,6 +792,7 @@ protected function get_access_token($refresh_token) {
789792 if (!($ this ->access_token = getcache ('access_token ' , $ this ->disktag ))) {
790793 $ p =0 ;
791794 $ tmp1 ['refresh_token ' ] = $ refresh_token ;
795+ $ tmp1 ['grant_type ' ] = 'refresh_token ' ;
792796 while ($ response ['stat ' ]==0 &&$ p <3 ) {
793797 $ response = curl ('POST ' , $ this ->auth_url , json_encode ($ tmp1 ), ["content-type " =>"application/json; charset=utf-8 " ]);
794798 $ p ++;
0 commit comments