1

Sending files to Telegram

Topic: Sending files to Telegram

Hi Wialon developers

Is there any possibility to send files from Wialon to any other server using POST/GET?
The idea is a way to send exported reports files to another server using POST/GET. We need it to send these files via Telegram messenger to customer ID.

2

Sending files to Telegram

(edited by shmi 27/02/2017 13:34:07)

Re: Sending files to Telegram

Hello

For now Wialon can't send files to Telegram
But you can get exported report file using Remote API and then send this file whenever you want (email, Telegram etc)

Here's sample how to export report result to PDF using PHP (change all variables to yours)

<?
    $url = 'https://hst-api.wialon.com';
    $token = TOKEN;
    $filename = 'new.pdf';

    // login request
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url.'/wialon/ajax.html?svc=token/login');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'params={"token":"'.$token.'"}');
    $out = curl_exec($ch);
    curl_close($ch);
    $out = json_decode($out, true);

    $sid = $out['eid'];

    // exec report
    $params = array(
        reportResourceId=>RESOURCE_ID,
        reportTemplateId=>REPORT_TEMPLATE_ID,
        reportObjectId=>UNIT_ID,
        reportObjectSecId=>0,
        interval=>array(
            from=>0,
            to=>1,
            flags=>0x02
        )
    );
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url.'/wialon/ajax.html?svc=report/exec_report&sid='.$sid);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'params='.json_encode($params));
    $out = curl_exec($ch);
    curl_close($ch);

    // export result
    $params = array(
        format=>2,
        outputFileName=>$filename,
        compress=>0
    );
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url.'/wialon/ajax.html?svc=report/export_result&sid='.$sid);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'params='.json_encode($params));
    $result = curl_exec($ch);
    $headers = curl_getinfo($ch);
    curl_close($ch);

    header('Content-type: '.$headers['content_type']);
    header('Content-Disposition: attachment; filename="'.$filename.'"');
    header('Content-Length: '.strlen($result));

    echo $result;
?>
3

Sending files to Telegram

Re: Sending files to Telegram

Hi Wialon developers
Is there any possibility to send files from Wialon to any other server using POST/GET?
The idea is a way to send exported reports files to another server using POST/GET. We need it to send these files via Telegram messenger to customer ID.

Dear Team,

The question above is for February, Is there any success that we can command the notifications to Telegram? We also have clients in need of it.

4

Sending files to Telegram

Re: Sending files to Telegram

shmi, this post is a old post and you have implemented Telegram Notification, but is it possible to implement a new Job type to execute and send reports to Telegram?

5

Sending files to Telegram

Re: Sending files to Telegram

Dear Hamed, hhamedk
I appreciate you pinging us on this topic.

Surely we can imagine how сool this enhancement can be, especially for partners from those regions where Telegram is a popular messenger platform. On the other side, it still has pretty limited usage and I would say cannot be placed on one level with such a job as e.g. sending a report by e-mail (the latter will be definitely used much more widely) and generally current jobs are more global in comparison with reports to be sent to Telegram which has regional constraints.

However, as we are thinking about so-called jobofications (combining jobs and notifications), sending reports to Telegram may find its place there as we really want for our jobs to evolve.

With this said, there are no immediate actions that will be taken in this regard, but as soon as (OR if) we come closer to jobofications, we will definitely include such a request in the scope.

Maria Starikova,
Wialon Hosting Product manager, Gurtam