customize user to user request - facebook-graph-api

Is there a way to customize the user to user request link in the notification the recepient receives in his/her notifications jewel? I'm trying to direct the receipient of the request to a specific competition room upon clicking on the notification.
Example - A request is sent to the user to be a pitcher in a particular baseball game (Yankees vs. cubs), can the user request notification take him to the particular baseball game and not just the home page or game directory? Otherwise how will the player know what the request is for or where to go upon ariving on the home canvas page?
Thank you in advance!

I know I am very late answering this question. But I too faced a lot of difficulty figuring this out at the beginning. I hope my answer would help others facing the same difficulty too.
There is a data parameter for each request object. You can find out about the parameters here. This can be used to track which object is being sent/received. For example, you can use an integer or a string on your client side to tell you which kind of object the particular request is. The sample FB.ui call may look like this:
var obj = {
method: 'apprequests',
title: 'Here\'s something to help you out.',
message: s_message,
data: i_giftIndex
};
FB.ui(obj, GiftCallback);

Related

Embedded graphics in original mail change to attached graphics in reply when using exchangelib in python

We have a python script that replies to incoming emails using exchangelib. User A sends us an email that can contain a picture/graphic (e.g. company logo in signature line). Our script is able to reply to his mail, and user A will get our reply. Unfortunately, the picture/graphic that was embedded in the original mail to us, is now an attached file instead of an embedded picture.
Here is the code that we're using:
origmsg.reply(
subject='Re: ' + origmsg.subject,
body="This is my reply to your inquiry...."
)
I understand that for new messages the HTML code needs to include a reference to the attached file to make it embedded. How can this be done in a reply?
Thanks.
https://ecederstrand.github.io/exchangelib/#attachments has some example of embedding images in emails.
The .reply() method is for simple replies. You may need to call .create_reply() instead and edit the returned ReplyToItem object as needed before calling .send() on it.
If you have even more special requirements, you can call .save() on the ReplyToItem object to save it as a draft, fetch the draft as a plain Message object with account.drafts.get(id=reply_to_item_id) and do whatever you need to do before sending the draft.

WSO2 - Add local authentication step BEFORE basic auth

WSO2 5.3.0. I am attempting to put in a local authentication step into my flow BEFORE basic auth runs. This is to aid in upgrading our password hashing algorithm (see this other question I asked)
The problem (I think) I am running into is that the initiateAuthenticationRequest is not being called for my new local authenticator (so username is null at the time, the basic authenticator runs to pop the login screen and fill it in, but my code never reruns).
EDIT: My initiateAuthenticationRequest was being skipped because canHandle was evaluating to true. If the method returns false initiateAuthenticationRequest gets called (Code reference here )
My current conundrum is how to pass the http request parameters onto the next step (the BasicAuthenticator) such that my login screen doesn't show up twice. Any help with this issue is appreciated.
EDIT 2: The request parameters are being passed along, but something else is causing BasicAuthenticator.initiateAuthenticationRequest to be called (see same code reference above). It looks like it is because the attribute "commonAuthHandled" is set to true on the request, but I can't find where that's happening, so help finding THAT is what I'm currently looking for
My solution here was to override the process method (after reading this code more carefully I realized that my step was toggling the commonAuthHandled bit back to true after processing its response)
A little hacky, but it seems to be working

Ask for missing DB data with Alexa

I'm trying to do the following with Alexa:
When a user say: open APP_NAME
I'm checking the DynamoDB to see if I have the name of the suer
if not I'd like to ask for the name before I tell what the app can do
I did try to use
this.emit(":delegate", "name_add");
From the Intent that is triggered when you say "open APP_NAME", this means that in the Hello intent I make a query, check if I have the name, and if not I'd like to trigger another Intent to get the missing data.
But when I use Delegate, the "name_add" intent is not being triggered.
My questions
When I'm in one intent that relies on data from the DB, and I see that there is data missing, how should I go about collecting this missing data? Mind you, once this data is in the DB I won't ask the user about it. So it is a one time thing.
Meaning I know how to take advantage of slots, when you ask for example from where are you flying to where. Because this is something that Alexa will ask each time. But what when you need to do this one time?
The problem is, you cannot delegate to a new intent. Read about Dialog Directives here.
Note that you cannot change intents when returning a Dialog directive, so the intent name and set of slots must match the intent sent to your skill.
So you are going to have to restructure your intents.
Suggested Structure:
Normally, your helloIntent (when the user opens your skill 'naked': "Alexa, open mySkill." instead of 'with clothing': "Alexa, open mySkill and do something"), this is when you want to direct the user into saying what to do that will trigger your main intents.
So the helloIntent will simply respond with: "Hello, welcome to mySkill, you can say things like, do something, or, do something else"
The user then says one of those things, which is an utterance of your other intents, therefore triggering one of those intents, lets call one: "checkDatabase".
Now that you are inside of "checkDatabase" intent, you can have a required slot called name. This is when you can check the DB for a user's name and fill the slot yourself, or delegate back to Alexa to elicit name.
Things to know:
1) Delegate only works with required slots of the intent. You are delegating to Alexa to figure out what slots are needed to be filled and which to elicit first. She figures this out based on the order of the required slots you have set up for the intent in the Console.
2) this.emit(':delegate', updatedIntent); (using the Alexa SDK) needs the second parameter updatedIntent to be an object of the full intent information which includes the name, slots and confirmationStatus (see Intent Object here). If you fill slots yourself, this is how you return the 'updated' intent information.
3) For more control in which slots to elicit and with a specific message, use ElicitSlot Directive.
Which in the Alexa SDK is: this.emit(':elicitSlot', slotToElicit, speechOutput, repromptSpeech, updatedIntent) Read about that here.
(ElicitSlot must be used to elicit unrequired slots)

Python Selenium Alert Authentication Trouble

I am trying to access a website that requires a login thru an alert box such as the one below:
I have tried to look up many different ways to do this and they dont seem to work. what i have tried are listed below:
Didnt work and gave me the same login alert.
start_url = 'http://username:password#example.com'
agent.get(start_url)
Keep getting an error message saying "NoAlertPresentException: Message: no alert open"
start_url = 'http://www.example.com'
alert = agent.switch_to_alert()
alert.send_keys("username")
alert.send_keys("password")
Get an error saying webdriver has no attribute "switchTo"
start_url = 'http://www.example.com'
agent.switchTo().alert().sendKeys("username")
I have to use Chrome because of the versions of IE and Firefox I have and can get, do not support the functions in the site
I have been having this exact same issue for some time now - with my end goal being to do this headless (in the background without visually launching an instance of Chromedriver).
Non-Ideal Solution 1:
I first used a library called pynput to automatically type the credentials in to the alert box and click the ok button, it was pretty simple to get working but:
still didn't work headlessly
I had to be focused on the browser or it would type the credentials elsewhere
This worked great in the meantime as everywhere I looked online it seemed like there was nothing I could do to overcome authentication alerts headlessly...
I'm a relative beginner (started programming <1 year ago) so perhaps I just wasn't looking in the right places!
I've now solved this issue though like so:
First I logged in to the alert as normal on Chrome while monitoring the Network section of devtools to get a good look at the GET request for the protected page screencap here:
Upon seeing that the Authorization was Basic (this will work for Bearer too) I tested just copying the same request in Postman with this header and it worked! Now if only there was a way to make http requests from Selenium???
I first tried the library selenium-requests (which didn't work for me: I got the same error as this person https://github.com/cryzed/Selenium-Requests/issues/33
This library seems absolutely excellent and exactly what I needed, I just don't currently have the know-how to get past firewalls/whatever was stopping me at this stage...
What eventually worked for me was the library selenium-wire. I followed this guide https://pypi.org/project/selenium-wire/#intercepting-requests-and-responses to have the webdriver navigate to the protected page as normal, but intercept the request and add the Authorization header before sending it :) now this works for me totally headlessly. Granted, this won't work on more secure websites but I hope it helps someone having the same issue.
This is Pythoncode
Problem with alert boxes (especially sweet-alerts is that they have a
delay and Selenium is pretty much too fast)
An Option that worked for me is: (just exchange the button click in the end with whatever action you want to have)
while True:
try:
driver.find_element_by_xpath('//div[#class="sweet-alert showSweetAlert visible"]')
break
except:
wait = WebDriverWait(driver, 1000)
confirm_button = driver.find_element_by_xpath('//button[#class="confirm"]')
confirm_button.click()
Note to 2: Here is probably the error due to the alert taking more time to load than the single elements (such as username, etc.)
Note to 3.: I think it should be switch_to

Showing progress view when communicating with web-service

in my application start, i'm requesting data and parsing by communicating with web-service via JSON, this work takes sometime 2 seconds, so i want to show the user a UIProgressView when this work is being executed and when it's done, i will redirect the user to the main view of my application, can you please help me there ? what objects to use essentially and if you have tutorials tips, i wil be glad, thx in advance :)
Look into ASIHTTPRequest. You're going to want to use the setDownloadProgressDelegate: method to hook it up to your progress indicator. Something like this:
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadProgressDelegate:someProgressIndicator];
[request startSynchronous];
For further reading see the relevant portion of the documentation here:
http://allseeing-i.com/ASIHTTPRequest/How-to-use#tracking_progress