PHPackages                             playable-cn/ten-im - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. playable-cn/ten-im

ActiveLibrary

playable-cn/ten-im
==================

腾讯云即时通信 SDK for PHP

1.2.0(2y ago)13MITPHPPHP &gt;=7.0

Since Jun 14Pushed 2y agoCompare

[ Source](https://github.com/playable-cn/IM)[ Packagist](https://packagist.org/packages/playable-cn/ten-im)[ RSS](/packages/playable-cn-ten-im/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

 腾讯云 IM 服务端 SDK for PHP
========================

[](#-腾讯云-im-服务端-sdk-for-php-)

腾讯云 IM.

[![StyleCI build status](https://camo.githubusercontent.com/6d9710b6aab824a7e4d6638a57d230726ee21e27fe4586cd582dd45b4cce7986/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3232303235383737352f736869656c64)](https://camo.githubusercontent.com/6d9710b6aab824a7e4d6638a57d230726ee21e27fe4586cd582dd45b4cce7986/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3232303235383737352f736869656c64)[![Latest Stable Version](https://camo.githubusercontent.com/8caf2e585206d9cadb321f2e702a0382a545209d4a4cf32b5688eab6445cd519/68747470733a2f2f706f7365722e707567782e6f72672f686564657169616e672f74656e2d696d2f76)](//packagist.org/packages/hedeqiang/ten-im)[![Total Downloads](https://camo.githubusercontent.com/ca1807768291670e9638027cb5705a0ac80f0ef6877ccc565ca6867ad2319fa8/68747470733a2f2f706f7365722e707567782e6f72672f686564657169616e672f74656e2d696d2f646f776e6c6f616473)](//packagist.org/packages/hedeqiang/ten-im)[![Latest Unstable Version](https://camo.githubusercontent.com/24d68cdc81022f6188f8700b3f4e61f8c265ec8aa2b8788d1112859c2cf1f53f/68747470733a2f2f706f7365722e707567782e6f72672f686564657169616e672f74656e2d696d2f762f756e737461626c65)](//packagist.org/packages/hedeqiang/ten-im)[![License](https://camo.githubusercontent.com/be17611d88164713709811a4db36c0cfc8dee9084dbcbed5093a369e99603d1f/68747470733a2f2f706f7365722e707567782e6f72672f686564657169616e672f74656e2d696d2f6c6963656e7365)](//packagist.org/packages/hedeqiang/ten-im)

安装
--

[](#安装)

```
$ composer require playable-cn/ten-im -vvv
```

> 说明：本项目默认会引入 [tencent/tls-sig-api-v2](https://github.com/tencentyun/tls-sig-api-v2-php) 扩展包，所以你不需要手动引入 `tencent/tls-sig-api-v2`,否则可能会造成依赖冲突

配置
--

[](#配置)

使用本扩展前需要登录 [即时通信 IM 控制台](https://console.cloud.tencent.com/avc) 创建应用，配置管理员、获取 app\_id、Key 等关键信息

更多请查看并熟读 [即时通信 IM 服务端API](https://cloud.tencent.com/document/product/269/32688)

[REST API 接口列表](https://cloud.tencent.com/document/product/269/1520)

使用
--

[](#使用)

```
config 配置
SDK_APP_ID=
IDENTIFIER=
IDENTIFIER=
SECRET_KEY=
REGION=
// REGION 默认zh，还可以配置：sgp、kr、ger、ind、usa

```

> 其中 `send` 方法接收三个参数。第一个参数 $servicename : 内部服务名，不同的 servicename 对应不同的服务类型；第二个参数 `$command`：命令字，与 servicename 组合用来标识具体的业务功能；第三个参数为请求包主体

> 示例：`v4/im_open_login_svc/account_import`，其中 `im_open_login_svc` 为 `servicename`； `account_import` 为 `command`

请求包示例：

```
{
    "From_Account":"id",
    "ProfileItem":
    [
        {
            "Tag":"Tag_Profile_IM_Nick",
            "Value":"MyNickName"
        }
    ]
}
```

### 导入单个帐号

[](#导入单个帐号)

```
require __DIR__ .'/vendor/autoload.php';

use Hedeqiang\TenIM\IM;

$config = [
    'sdk_app_id' => '',
    'identifier' => '',
    'secret_key' => '',
    'region' => '',
];
$im = new IM($config);
$params = [
    'Identifier' => "hedeqiang",
    'Nick'       => 'hedeqiang',
    'FaceUrl'    => '',
];

print_r($im->send('im_open_login_svc','account_import',$params));
```

### 获取用户在线状态

[](#获取用户在线状态)

```
