How to send a message to a Telegram channel using the HTTP bot sendMessage API

Here’s a practical example how to send a message to a Telegram channel using a Telegram Bot and the HTTP bot sendMessage API.

In order to be able to do so, you will have to the following:

  1. Create a Telegram public channel (we’ll make this private later)
  2. Create a Telegram BOT via BotFather
  3. Set the bot as administrator in your channel

After you’ve completed the steps above, we can now go ahead and send a message to the channel by issuing and HTTP GET request to the Telegram BOT API at the following URL (you can do this in your browser):

https://api.telegram.org/bot[BOT_API_KEY]/sendMessage?chat_id=[CHANNEL_NAME]&text=[MESSAGE_TEXT]

where:

BOT_API_KEY is the API Key generated by BotFather when you created your bot
CHANNEL_NAME is the handle of your public channel (e.g. @channel_name)
MESSAGE_TEXT is the message you want to send (URL-encoded)

Example HTTP API call response:

{
  "ok": true,
  "result": {
    "message_id": 2,
    "chat": {
      "id": -1001363941800,
      "title": "TestChannel",
      "username": "usefulmix_channel",
      "type": "channel"
    },
    "date": 1538926255,
    "text": "Test message"
  }
}

So far, so good, but let’s consider that you’ll want this new channel to be private so that only you and the bot (and whoever you decide to invite in the channel) will see the messages.

So we need to make the channel private, however in doing so our above HTTP API call will stop working and this is what trying to prublish a message will look like:

{
  "ok": false,
  "error_code": 400,
  "description": "Bad Request: chat not found"
}

To get around this, all you need to do is look at the public HTTP API call we made initially and pick up the "id": -1001363941800 as this is the unique id of our channel which we’ll be switching to after we make our channel private from public.

So now the API call becomes:

https://api.telegram.org/bot[BOT_API_KEY]/sendMessage?chat_id=-1001363941800&text=[MESSAGE_TEXT]

And voila, you now have a private Telegram channel, where you can send messages via the HTTP bot sendMessage API. This can be very useful when you have some online services that provide you with a callback mechanism and can call you HTTP API endpoint so that you get notified of whatever in real time.

WordPress Permissions Update Error – How to Fix

If you’re running into the WordPress core upgrade failure or plugins/themes update issues when you try to update/upgrade via the admin interface, all you need to do is reset the file permissions on the core files and the problem will most likely be fixed and you’ll be able to process with the update.

Provided you have SSH access to your server, run the following set of commands and this will likely fix your issue.

Reset all file permissions  664:

 find /path/to/site/ -type f -exec chmod 664 {} \;

Reset all directory permissions to 775:

 find /path/to/site/ -type d -exec chmod 775 {} \;

Reset the group ownership to the wordpress or www-data group (or whatever your nginx/apache group name is):

 chgrp -R wordpress /path/to/wodpress_site_directory/

After you run these commands you should be able to successfully update WordPress code, plugins and themes with no issues.

Install Archidroid v3.0.0 experimental ROM on the Galaxy S3 (GT-I9300)

XDA-forums original Archidroid thread for Samsung Galaxy S3 (GT-I9300): [ROM] [4.4.4] [CyanogenMod] [Linaro 4.9] [Excellent] [06/09/14] ArchiDroid V2.5.3

Currently the stable version is version 2.3.5, and I wanted to go with the 3.0.1 experimental version, and here’s how to do just that:

1. Go to the Archidroid’s github repository: i9300-cm-experimental

2. And download the repository zip: direct download zip of i9300-cm-experimental

3. After the download is finished, unzip the archive.

4. Download 7zip from here: 7zip.org

5. After you’ve extracted the i9300-cm-experimental zip archive, go into the directory, select everything (Ctrl+A shortcut) and right click and select 7zip > Add to archive… and select Compression Level: Fastest and the Compression method: Deflate and click ok. Continue reading “Install Archidroid v3.0.0 experimental ROM on the Galaxy S3 (GT-I9300)”

Delete a Github forked repository

Navigate to the repository you want to delete.

In the repository action bar, click Settings.

repo-actions-settings

Under Danger Zone, click Delete this repository.

repo-delete

Read the warnings.

To verify that you’re deleting the correct repository, type the name of the repository you want to delete.

repo-delete-confirmation

Click I understand the consequences, delete this repository.