PHP code example of tourze / wechat-work-contracts
1. Go to this page and download the library: Download tourze/wechat-work-contracts library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tourze / wechat-work-contracts example snippets
use Tourze\WechatWorkContracts\UserInterface;
use Tourze\WechatWorkContracts\CorpInterface;
use Tourze\WechatWorkContracts\AgentInterface;
use Tourze\WechatWorkContracts\UserLoaderInterface;
// Implement the interfaces in your application
class MyWechatUser implements UserInterface
{
public function getUserId(): ?string
{
return $this->userId;
}
public function getName(): ?string
{
return $this->name;
}
}
class MyUserLoader implements UserLoaderInterface
{
public function loadUserByUserIdAndCorp(string $userId, CorpInterface $corp): ?UserInterface
{
// Your implementation to load user from WeChat Work API
return new MyWechatUser($userId);
}
public function createUser(CorpInterface $corp, AgentInterface $agent, string $userId, string $name): UserInterface
{
// Your implementation to create user
return new MyWechatUser($userId, $name);
}
}
interface AgentInterface
{
public function getAgentId(): ?string;
public function getWelcomeText(): ?string;
}
interface CorpInterface
{
public function getCorpId(): ?string;
}
interface DepartmentInterface
{
public function getId(): ?int;
public function getName(): string;
}
interface UserInterface
{
public function getUserId(): ?string;
public function getName(): ?string;
}
interface UserLoaderInterface
{
public function loadUserByUserIdAndCorp(string $userId, CorpInterface $corp): ?UserInterface;
public function createUser(CorpInterface $corp, AgentInterface $agent, string $userId, string $name): UserInterface;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.