function putLogs()

in sample/credentialsProviderSample.php [18:45]


function putLogs(Aliyun_Log_Client $client, $project, $logstore)
{
    $topic = 'TestTopic';

    $contents = array( // key-value pair
        'TestKey' => 'TestContent',
        'kv_json' => '{"a": "b", "c": 19021}'
    );
    $logItem = new Aliyun_Log_Models_LogItem();
    $logItem->setTime(time());
    $logItem->setContents($contents);
    $logitems = array($logItem);
    $request = new Aliyun_Log_Models_PutLogsRequest(
        $project,
        $logstore,
        $topic,
        null,
        $logitems
    );

    try {
        $response = $client->putLogs($request);
    } catch (Aliyun_Log_Exception $ex) {
        var_dump($ex);
    } catch (Exception $ex) {
        var_dump($ex);
    }
}