Skip to content

Commit

Permalink
complete part one
Browse files Browse the repository at this point in the history
  • Loading branch information
DoveChen committed Apr 7, 2020
1 parent 262cd44 commit b538274
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,34 @@ Usage
Once the extension is installed, simply use it in your code by :

```php
<?= \dovechen\yii2\weWork\AutoloadExample::widget(); ?>```
/** @var Work $workApi */
$workApi = \Yii::createObject([
'class' => Work::className(),
'corpid' => $corpid,
'secret' => $secret,
]);

/** @var Work $agentApi */
$agentApi = \Yii::createObject([
'class' => Work::className(),
'corpid' => $corpid,
'secret' => $agentSecret,
]);

/** @var ServiceWork $serviceWork */
$serviceWork = \Yii::createObject([
'class' => ServiceWork::className(),
'suite_id' => $suiteId,
'suite_secret' => $suiteSecret,
'suite_ticket' => $suiteTicket,
'auth_corpid' => $authCorpid,
'permanent_code' => $permanentCode,
]);

/** @var ServiceProvider $serviceProvider */
$serviceProvider = \Yii::createObject([
'class' => ServiceProvider::className(),
'provider_corpid' => $providerCorpid,
'provider_secret' => $providerSecret,
]);
```
4 changes: 2 additions & 2 deletions ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace dovechen\yii2\weWork;

require_once "./components/errorInc/error.inc.php";
require_once "components/errorInc/error.inc.php";

use dovechen\yii2\weWork\components\BaseWork;
use dovechen\yii2\weWork\components\Utils;
Expand Down Expand Up @@ -96,7 +96,7 @@ protected function RefreshProviderAccessToken ()
}

$time = time();
$this->_HttpCall(self::SERVICE_GET_PROVIDER_TOKEN, 'GET', ['corpid' => $this->provider_corpid, 'provider_secret' => $this->provider_secret]);
$this->_HttpCall(self::SERVICE_GET_PROVIDER_TOKEN, 'POST', ['corpid' => $this->provider_corpid, 'provider_secret' => $this->provider_secret]);

$this->repJson['expire'] = $time + $this->repJson["expires_in"];
$this->setCache('provider_access_token', $this->repJson, $this->repJson['expires_in']);
Expand Down
8 changes: 8 additions & 0 deletions Work.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ public function userConvertTouserId ($openid, &$userId)
$userId = Utils::arrayGet($this->repJson, 'userid');
}

public function externalConvertToOpenid ($externalUserid, &$openid)
{
Utils::checkNotEmptyStr($externalUserid, 'external_userid');
self::_HttpCall(self::EXTERNAL_CONTACT_CONVER_TO_OPENID, 'POST', ['external_userid' => $externalUserid]);

$openid = Utils::arrayGet($this->repJson, 'openid');
}

public function userAuthSuccess ($userId)
{
Utils::checkNotEmptyStr($userId, 'userid');
Expand Down
2 changes: 1 addition & 1 deletion src/dataStructure/MiniprogramNoticeMessageContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static function MessageContent2Array ($content, &$arr)
Utils::setIfNotNull($content->msgtype, "msgtype", $arr);

$args = [];
Utils::setIfNotNull($content->appid, "key", $args);
Utils::setIfNotNull($content->appid, "appid", $args);
Utils::setIfNotNull($content->page, "page", $args);
Utils::setIfNotNull($content->title, "title", $args);
Utils::setIfNotNull($content->description, "description", $args);
Expand Down

0 comments on commit b538274

Please sign in to comment.