telegram inline bot - InlineQueryResultCachedPhoto does not show title and description - telegram

I'm using telegram bot api for implementing an inline bot. For sending query result to the user, I'm using answerInlineQuery method in this way. This is just an example for showing a photo that exist on telegram server to user:
$results = array(
array(
"type" => "photo",
"id" => "1",
"photo_file_id" => the file id,
"title" => "test title",
"description" => "test description",
"caption" => "test caption",
"parse_mode" => "HTML"
),
);
$postFields["results"] = json_encode($results);
$postFields["cache_time"] = 0;
//send $postFields to telegram bot api server with curl
This works and after user sending inline query, one image shows as the result list. But the problem is two fields title and description does not show in the result list, even these are exist in telegram api documentation here.
What's is the problem and whay these two fields does not present in the result list?

Related

Using a single Cloudflare account in Wordpress with WP Super Cache with visible API key

We are starting to use Cloudflare on a few Wordpress client accounts and notice in the CDN settings that my email address and API key are visible to the client.
Is this a potential security issues where others can see my Cloudlflare email address and API key? Should I be using 1 Cloudflare account per client account?
Here is a screenshot (i have blurred the API key and deleted the email input box in the console) but both these values are visible to the customer.
What is the worse thing they could do with these 2 pieces of data?
you have to use tokens instead of global api key. you strict token to certain zone only
This only will NOT solve the problem, you have to manually modify wp fastest cache plugin to modify the request to match API tokens usage.
the requests can be found in inc\cdn.php
The modified file:
https://gist.github.com/ahmed-abdelazim/7c8170f7fc4e821c6b015d770fcbf14a
so
$header = array("method" => "DELETE",
'headers' => array(
"X-Auth-Email" => $email,
"X-Auth-Key" => $key,
"Content-Type" => "application/json"
),
"body" => '{"purge_everything":true}'
);
is converted to
$header = array("method" => "DELETE",
'headers' => array(
//"X-Auth-Email" => $email,
"Authorization" => "Bearer ".$key,
"Content-Type" => "application/json"
),
"body" => '{"purge_everything":true}'
);
and this occured five times in the plugin in the cdn.php file
simply creating API Token worked for me. There are some pre made template. There was for wordpress one as well. Just selected and created and added it to wp fastest cache and that worked.

telegram bot api - send additional data with replay keyboard

I'm working on telegram bot api and I sendReplayKeyboard with my message text to user. When a user click on a button, telegram sends a post with below structure to my webhook. Here is json structure of post:
{
"update_id": *******,
"message": {
"message_id": ***,
"from": {
"id": *****,
"is_bot": false,
"first_name": "*****",
"username": "******",
"language_code": "en-US"
},
"chat": {
"id": *****,
"first_name": "******",
"username": "*****",
"type": "private"
},
"date": 1518716587,
"text": "Button Text"
}
}
My problem is telegram does not accept any additional data for replay keyboard button. So, I have to check message.text with string and this is not a good practice. For example if the button has emoji, the emoji code must be in the check. Also, I have different menu type and I need to find out type of clicked button, but I have just text of the button. So I need to assign id and type to each button. But I don't know how can I do it.
Here is the post data that my bots sends to user:
$keyboard = array(
'resize_keyboard' => true,
'keyboard' => array(
array(
array(
"text" => "Button Text"
//There is not any `id` or `type`,...
)
)
)
);
$post_fields = array(
'chat_id' => **********
'text' => ************,
'reply_markup' => json_encode($keyboard)
);
Note: I don't want to InlineKeyboard and I need to use RelplayKeyboard.
If it's not possible, is there any alternative way? For example put additional data in button text and hide it from user.
It seems you need to save each user stat, so you can elect suitable reaction to similar text of button.
Also note that emoji is not horrible! and you don't need emoji code!
You just need to compare text that include emoji with a predefined string:
if('راهنما 💡'===$receivedText)
doSomeMagic();

Facebook post wirth php error: (#200) The user hasn't authorized the application to perform this action

i want to post from my website to my facebook site. i have created a app for my site. I use this code (i replace data from my app with '[]'):
require_once 'lib/php-graph-sdk-5.4/src/Facebook/autoload.php';
// initialize Facebook class using your own Facebook App credentials
// see: https://developers.facebook.com/docs/php/gettingstarted/#install
$access_token = '[aaccesstoken]';
$config = array();
$config['app_id'] = '[appid]';
$config['app_secret'] = '[appsecret]';
$config['fileUpload'] = false; // optional
$fb = new \Facebook\Facebook($config);
// define your POST parameters (replace with your own values)
$params = array(
"access_token" => $access_token, // see: https://developers.facebook.com/docs/facebook-login/access-tokens/
"message" => "Test Message",
"link" => "http://www.frauen-styles.de",
"picture" => "http://www.frauen-styles.de/site/assets/files/3545/20.jpg",
"name" => "Test Name",
"caption" => "Caption",
"description" => "Beschreibung"
);
// post to Facebook
// see: https://developers.facebook.com/docs/reference/php/facebook-api/
try {
$ret = $fb->post('/me/feed', $params);
echo 'Successfully posted to Facebook';
} catch(Exception $e) {
echo $e->getMessage();
}
what i'm doing wrong? im administrator of the page. support tells me that no publish_pages is requiered for the app for admins. I only want to send a post from my website to my facebook-page.
support tells me that no publish_pages is requiered
As you can read in the API reference in the official docs, you do need publish_pages and manage_pages to post to a Page (as Page).
Docs: https://developers.facebook.com/docs/graph-api/reference/page/feed#publish

Silex token authentication

I create my first app with silex. Only logged in users can use the app. In the first page i create a login form, so the user can authenticate. My security provider look like:
$app->register(new Silex\Provider\SecurityServiceProvider(), array(
'security.firewalls' => array(
'secure_area_edison' => array(
'pattern' => '^/admin/',
'form' => array('login_path' => '/', 'check_path' => '/admin/login_check'),
'logout' => array('logout_path' => '/admin/logout', 'invalidate_session' => true),
'users' => function () use ($app) {
return new App\Services\UserProvider($app['db']);
},
),
)
));
Every url after '/admin' require that the user was successfull authenticated. Everything works fine and now i want to extend my app with an API. I create a new controller which retrieves data from database and return a JSON reponse, this work also fine.
But how can the user authenticate for this API? Should i create a new column in my user table like "hash" or "token"? Users which will retrieve the JSON Response must send the token in every get request, is this the correct way?
The url can look:
/admin/api/allProducts/token/<TOKEN>
you should use token base authentication instead of passing token in every get request.
refer : https://github.com/thcolin/silex-simpleuser-jwt

Can you create a secondary index on a repeated field in Riak?

Consider a JSON object such as:
{
name: 'ben',
employer: 'The Sherwin-Williams Company',
emails: ['ben#gmail.com', 'ben#sherwin-williams.com']
}
In MongoDB you can index the emails field such that you can find any object with 'ben#gmail.com' as an email. Is this possible in Riak? I couldn't tell from reading the docs.
You certainly can, but you have to manually enter the index entries.
Here's an example in Ruby:
require 'riak'
client = Riak::Client.new(:protocol => "pbc", :host => "127.0.0.1", :pb_port => 10047, :http_port => 10048)
ben = client['people'].get_or_new('ben')
ben.data = { :name => "ben",
:employer => "The Sherwin-Williams Company",
:emails => ['ben#gmail.com', 'ben#sherwin-williams.com'] }
ben.indexes['email_bin'] << "ben#gmail.com"
ben.indexes['email_bin'] << "ben#sherwin-williams.com"
ben.store
Now you can look it up via the ruby library, or through your web browser at http://127.0.0.1:10018/buckets/people/index/email_bin/ben#gmail.com
On my system this returns:
{"keys":["ben"]}
I know the Java and the Ruby Riak libraries support adding/editing index entries, I will have to check on the others and get back to you though.

Resources