How to use FQL(Facebook Query Language) with asp.net? - asp.net

I need to use FQL to get user's current Facebook Chat status. Its not supported by Facebook Graph API.
"online_presence" parameter returns the user's Facebook Chat status as i studied on http://developers.facebook.com/docs/reference/fql/user
But i didn't find anything helpful which describe how i can use FQL in asp.net.
Can anyone show me an example how i can use FQL?
thanks

Hi you can use this sdk : http://facebooksdk.net/docs/web/getting-started/.
For use fql you need to do :
var client = new FacebookClient(THE_ACCESS_TOKEN);
dynamic me = client.Get("fql", new { q = "select online_presence from user where uid=me()"});
I let you parse the result and find how get the access token.

Related

Telegram channel- how to get access_hash?

I try really hard to understand howto use Telegram api with telethon. I have some Channels in Telegram, where i want to delete older Messages. Using inputpeerchannel() i need channel_id (No Problem) and channel_hash. I cant findout howto get this channel_hash by channel_id. Thank you from germany
In order to find channel access_hash, you should resolve channel username. Original MTProto method contacts.resolveUsername#f93ccba3 gets #username and returns channel info including access_hash.
In telethon you need to invoke ResolveUsernameRequest to call the above original MTProto method. You may use this code to resolve username to access_hash:
client = TelegramClient(session_file, api_id=00000, api_hash='XXXXX')
client.connect()
response = client.invoke(ResolveUsernameRequest("your_channel_id"))
print(response.chats[0].access_hash)
client.disconnect()
There are 4 ways to get access hash:
From a Group
From username
From contact list
From chats message
So, if you have id only, there is no way to get access hash

Call a Google App Maker App with a parameter

Hello i am new here so if i ask a stupid question please forgive me.
We at AppAtSchool are working with Google ApMaker and we want to call a published App with 2 parameters. How can we read those in App Maker? Thanks in advance!
I'm guessing, that you are trying to read page URL parameters. In this case you can pass parameters like this:
https://script.google.com/<SomeMagic>/exec/?param1=value1&param2=value2#PageName
And then read them in page onAttach event(https://developers.google.com/appmaker/ui/logic#events):
google.script.url.getLocation(function(location) {
var params = location.parameter;
var param1 = params.param1;
var param2 = params.param2;
// Use parameters...
});
Maybe you also will need a way to genarate such links with parameters:
Integration between different Google Appmaker Apps
you can call your application with url something like this: script.google.com/blablabla/#viewname/paramValue, and take param on client side and send it to server side.
If you pass parameters to your App Maker app through URL parameters, your app can read the parameters using the google.script.url.getLocation method:
google.script.url.getLocation(function(location) {
console.log(location.parameters);
console.log(location.hash);
});
Find more details in the documentation

Telegram bot: How to mention user by its id (not its username)

I am creating a telegram bot and using sendMessage method to send the messages.
it is easy to mention user using #username, But how to mention user when they don't have username?
If using the telegram app/web, we can mentioned the user by #integer_id (name), and telegram app/web will convert it into clickable text. integer_id will be generated automatically when we select the user, after typing #.
another background:
I am trying to use forceReply and I want to target user, if they have username, I can easily target them, by mentioning them on the text on sendMessage method.
the bot I am creating is a "quiz" like bot. where each player need to take turn, and the bot is sending them the question, each msg from bot will target different player.
NOTE: I am not disabling the Privacy Mode, I don't want telegram bombing my server with msg I don't need. it was overloading my cheap nasty server. so, disabling it not an option.
I am open for other solution, where the bot can listen to selected player.
thanks.
UPDATE 21/10:
I've spoke to BotSupport for telegram, they said, for now Bots can't mention user without username.
so in my case, I still keep using forceReply, and also, gave a short msg to user which doesn't have username to set it up, so they can get the benefit from forceReply function.
According to official documentation it is possible to mention user by its numerical id with markup:
[inline mention of a user](tg://user?id=123456789)
According to this link :
it is possible to mention user by its numerical id with markup:
Markdown style
To use this mode, pass Markdown in the parse_mode field
when using sendMessage. Use the following syntax in your message:
[inline mention of a user](tg://user?id=123456789)
and you can also use HTML style :
HTML style
To use this mode, pass HTML in the parse_mode field when using sendMessage. The following tags are currently supported:
inline mention of a user
Try this:
#bot.message_handler(func=lambda message: True)
def echo_message(message):
cid = message.chat.id
message_text = message.text
user_id = message.from_user.id
user_name = message.from_user.first_name
mention = "["+user_name+"](tg://user?id="+str(user_id)+")"
bot_msg = f"Hi, {mention}"
if message_text.lower() == "hi":
bot.send_message(cid, bot_msg, parse_mode="Markdown")
For python-telegram-bot you can do the following:
user_id = update.message.from_user['id']
user_name = update.message.from_user['username']
mention = "["+user_name+"](tg://user?id="+str(user_id)+")"
response = f"Hi, {mention}"
context.bot.sendMessage(chat_id=update.message.chat_id,text=response,parse_mode="Markdown")
No, this restriction is related to Telegram's privacy policy and prevention of abuse.
It is possible to mention a user when sending messages (BOT API), but that is not what you need:
[inline mention of a user](tg://user?id=<user_id>)
Links tg://user?id= can be used to mention a user by their id without using a username. Please note:
These links will work only if they are used inside an inline link. For example, they will not work, when used in an inline keyboard button or in a message text.
These mentions are only guaranteed to work if the user has contacted the bot in the past, has sent a callback query to the bot via inline button or is a member in the group where he was mentioned.
https://core.telegram.org/bots/api#markdown-style
you need to link to the text: "tg://user?id=" and id
user_id = 123456XX # id of the user to mention
chat_id = 123456XXX # chat id where to mention
user_name = name of user
await bot.send_message(chat_id, f"<a href='tg://user?id={user_id}'>{user_name}</a>", "HTML")
here is an example:
#dp.message_handler()
async def mention(msg: types.Message):
await msg.answer(f"<a href='tg://user?id={msg.from_user.id}'>{msg.from_user.full_name}</a>", "HTML")
Bots are able to tag users by their ID, they just can't do this using the official HTTP Bot API.
Update: Not necessairy anymore, since Telegram added native Support for this.
If you log into your bots account with MadelineProto (PHP) you can use this 'link' to mention someone by it's ID with parse_mode set to markdown
[Daniil Gentili](mention:#danogentili)

How can I allow new R users to send information to a Google Form?

How can I allow new R users to send information to a Google Form? (RSelenium requires a bit of set up, at least for headless browsing, so it's not the best candidate IMO but I may be missing something that makes it the best choice).
I have some new R users I want to get responses from interactively and send to a secure location. I have chosen Google Forms to pass the information to, as it allows one way sends of the info and doesn't allow the user access to the spreadsheet that is created from the form.
Here's a url of this form:
url <- "https://docs.google.com/forms/d/1tz2RPftOLRCQrGSvgJTRELrd9sdIrSZ_kxfoFdHiqD4/viewform"
To give context here's how I'm using R to interact with the user:
question <- function(message, opts = c("Yes", "No")){
message(message)
ans <- menu(opts)
if (ans == "2") FALSE else TRUE
}
question("Was this information helpful?")
I want to then send that TRUE/FALSE to the Google form above. How can I send a response to the Google Form above from within R in a way that I can embed in code the user will interact with and doesn't require difficult set up by the user?
Add on R packages are fine if they accomplish the task.
You can send a POST query. Here an example using httr package:
For example:
library(httr)
send_response<-
function(response){
form_url <- "https://docs.google.com/forms/d/1tz2RPftOLRCQrGSvgJTRELrd9sdIrSZ_kxfoFdHiqD4/formResponse"
POST(form_url,
query = list(`entry.1651773982`=response)
)
}
Then you can call it :
send_response(question("Was this information helpful?"))

EWS get selected mail from exchnage server in asp.net

I am fetching all the mails from exhange server using EWS and showing in a grid. When a user clicks on the mail i have to fetch all the details from the server and show.
How to fetch a specific mail from exchange server using its conversationId or any unique id.
You can use messageid which is unique to every email.You can then use the messageid to find the mailitem that u r looking from the entire list of emails in the mailbox(assuming u already have the code to get all the emails from a mailbox using EWS ,which u use to populate the grid view).
This should do what you are after:
// Assuming you already know what the ItemId is
ItemId i;
// Defines the properties returned for the EmailMessage, can also add ExtendedProperties to this.
PropertySet ps = PropertySet.FirstClassProperties;
// Accesing all properties
EmailMessage mail = EmailMessage.Bind(
Program.ExConn.Service,
new ItemId(i.UniqueId),
ps);
Note that the ItemId changes if the EmailMessage has moved folders, so you may get a ServiceResponseException with the ErrorCode of ServiceError.ErrorItemNotFound

Resources