PHP code example of dino.ma / im

1. Go to this page and download the library: Download dino.ma/im 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/ */

    

dino.ma / im example snippets




edeqiang\TenIM\IM;

$config = [
    'sdk_app_id' => '',
    'identifier' => '',
    'secret_key' => '',
];
$im = new IM($config);

$params = [
    'To_Account' => ['hedeqiang']
];

print_r($im->send('openim','querystate',$params));

{
	"ActionStatus": "OK",
	"ErrorInfo": "",
	"ErrorCode": 0,
	"QueryResult": [{
		"To_Account": "1",
		"State": "Offline"
	}]
}

$params = [
    'From_Account' => 'hedeqiang',
        'ProfileItem' => [
            ['Tag' => 'Tag_Profile_IM_Nick', 'Value' => 'hedeqiang'],
            ['Tag' => 'Tag_Profile_IM_Gender', 'Value' => 'Gender_Type_Male'],
            ['Tag' => 'Tag_Profile_IM_BirthDay', 'Value' => 19940410],
            ['Tag' => 'Tag_Profile_IM_SelfSignature', 'Value' => '程序人生的寂静欢喜'],
            ['Tag' => 'Tag_Profile_IM_Image', 'Value' => 'https://upyun.laravelcode.cn/upload/avatar/1524205770e4fbfbff-86ae-3bf9-b7b8-e0e70ce14553.png'],
        ],
];

print_r($im->send('profile','portrait_set',$params));

{
	"ActionStatus": "OK",
	"ErrorCode": 0,
	"ErrorInfo": "",
	"ErrorDisplay": ""
}

$params = [
    'SyncOtherMachine' => 1, // 消息不同步至发送方
    'From_Account' => '1',
    'To_Account' => '2',
    'MsgRandom' => 1287657,
    'MsgTimeStamp' => 1557387418,
    'MsgBody' => [
        [
            'MsgType' => 'TIMTextElem',
            'MsgContent' => [
                'Text' => '晚上去撸串啊'
            ]
        ]
    ]
];

print_r($im->send('openim','sendmsg',$params));

{
    "ActionStatus":"OK",
    "ErrorInfo":"",
    "ErrorCode":0,
    "MsgTime":1573179125,
    "MsgKey":"748144182_1287657_1573179125"
}

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