-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from LinkedDestiny/1.2.x
add miniprogram urlscheme api
- Loading branch information
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea/ | ||
vendor/ | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
|
||
namespace EasySwoole\WeChat\MiniProgram; | ||
|
||
|
||
use EasySwoole\WeChat\Exception\MiniProgramError; | ||
use EasySwoole\WeChat\Exception\RequestError; | ||
use EasySwoole\WeChat\Utility\NetWork; | ||
|
||
class UrlScheme extends MinProgramBase | ||
{ | ||
/** | ||
* 生成URL SCHEME | ||
* @param string $path | ||
* @param string $query | ||
* @param bool $isExpire | ||
* @param int $expireAt | ||
* @return array | ||
* @throws MiniProgramError | ||
* @throws RequestError | ||
*/ | ||
public function generate(string $path, string $query, bool $isExpire = false, int $expireAt = 0) | ||
{ | ||
$token = $this->getMiniProgram()->accessToken()->getToken(); | ||
$url = ApiUrl::generateURL(ApiUrl::URL_SCHEME_GENERATE, [ | ||
'ACCESS_TOKEN' => $token, | ||
]); | ||
|
||
$responseArray = NetWork::postJsonForJson($url, [ | ||
'jump_wxa' => [ | ||
'path' => $path, | ||
'query' => $query | ||
], | ||
'is_expire' => $isExpire, | ||
'expire_time' => $expireAt | ||
]); | ||
$ex = MiniProgramError::hasException($responseArray); | ||
if ($ex) { | ||
throw $ex; | ||
} | ||
|
||
return $responseArray; | ||
} | ||
} |