Skip to content

gemechis-elias/OCR-Scanner-Tg-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text from Image Scanner Telegram Bot ·

Build Status npm PRs Welcome GitHub license

Simple Telegram Bot to extract text from image based on ocr api

Simple Telegram Bot to extract text from image based on ocr api by Gemchis Elias

Check out The Sample Bot


Installing / Getting started

Go to @botfather and create a new bot. Copy your api token and setwebhook by pasting this link on browser.

· Change XXXXXX with your bot token
· Change url to domain you host the php file.

https://api.telegram.org/botXXXXXX/setWebHook?url=yourdomain.com/bot.php

Code to edit

Just edit 2nd line by changing api key on bot.php api key can be found here https://ocr.space/ocrapi

//Change OCR-KEY to your api key from ocr.space website
            $result = file_get_contents('http://api.ocr.space/parse/imageurl?apikey=<OCR-KEY-XXX>&url='.$id_url);
            $result=json_decode($result, true);
            $str='';
            foreach($result['ParsedResults'] as $pareValue) 
                {
                            $str.= strval($pareValue['ParsedText']);
                }
                if($str!=""){ 
                $re= 
                array(
                'chat_id' => $chatId, 
                'text' => "🔍Scanned Text:\n$str\n\n@horansoftware",
                'disable_web_page_preview' => false,);
                    send("sendMessage", $re);
                }   #end

Change Bot API Token

Don't forget pasting your bot token every where needed in the bot.php

$path = "https://api.telegram.org/bot<Your Bot Token>/";

Code Written by Gemechis Elias

About

simple telegram bot to extract text from images. ocr scanner bot based on ocr-space api.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages