From: Tim Düsterhus Date: Fri, 13 May 2022 14:01:16 +0000 (+0200) Subject: Use Guzzle in PackageAction::searchForPurchasedItems() X-Git-Tag: 6.0.0_Alpha_1~1302 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4f33a332b8aaf66e6c2fb1c9919063146c328c56;p=GitHub%2FWoltLab%2FWCF.git Use Guzzle in PackageAction::searchForPurchasedItems() see #4281 --- diff --git a/wcfsetup/install/files/bootstrap.php b/wcfsetup/install/files/bootstrap.php new file mode 100644 index 0000000000..e7645d67de --- /dev/null +++ b/wcfsetup/install/files/bootstrap.php @@ -0,0 +1,17 @@ + 'POST', - ], [ - 'username' => $this->parameters['username'], - 'password' => $this->parameters['password'], - 'wcfVersion' => WCF_VERSION, - ]); - - $request->execute(); - $reply = $request->getReply(); - $response = JSON::decode($reply['body']); - - $code = $response['status'] ?? 500; + $client = HttpFactory::makeClientWithTimeout(5); + $request = new Request( + 'POST', + 'https://api.woltlab.com/1.1/customer/purchases/list.json', + [ + 'content-type' => 'application/x-www-form-urlencoded', + ], + \http_build_query( + [ + 'username' => $this->parameters['username'], + 'password' => $this->parameters['password'], + 'wcfVersion' => WCF_VERSION, + ], + '', + '&', + \PHP_QUERY_RFC1738 + ) + ); + + $response = $client->send($request); + $payload = JSON::decode((string)$response->getBody()); + + $code = $payload['status'] ?? 500; switch ($code) { case 200: - if (empty($response['products'])) { + if (empty($payload['products'])) { return [ 'noResults' => WCF::getLanguage()->getDynamicVariable('wcf.acp.pluginStore.purchasedItems.noResults'), ]; } else { - WCF::getSession()->register('__pluginStoreProducts', $response['products']); - WCF::getSession()->register('__pluginStoreWcfMajorReleases', $response['wcfMajorReleases']); + WCF::getSession()->register('__pluginStoreProducts', $payload['products']); + WCF::getSession()->register('__pluginStoreWcfMajorReleases', $payload['wcfMajorReleases']); return [ 'redirectURL' => LinkHandler::getInstance()->getLink('PluginStorePurchasedItems'),