From the following link, I found out that we can send data to publisher over AMQP protocol, https://github.com/ppatierno/azuresblite-examples. So, how to implement the same, i.e) Send to publisher(with & without token), using Qpid-proton python?
send to a publisher means sending the message to a path like :
/Publishers/
You can use it as address for publishing message.
Paolo.
Related
Trying to understand how to receive an SMS in python using ACS.
ACS is able to send and receive messages according to their own page.
I've already managed to send a message. I sent a msg from my phone number to a public free phone on the page https://www.receivesms.co/
The code I used to send an msg is the following:
from azure.communication.sms import SmsClient
sms_client = SmsClient.from_connection_string("my_secret")
def send_message(sms_client, text):
sms_responses = sms_client.send(
from_="my_number",
to=["receiving_mumber"],
message=text,
enable_delivery_report=True,
tag="custom-tag",
)
print("sent!")
try:
send_message(sms_client, "Random msg")
except Exception as ex:
print("Exception:")
print(ex)
This was fairly simple because of the instructions on the ACS website however I haven't managed to find any info on how to receive an SMS using python.
Or how do receive incoming texts in python, is it even possible?
EDIT 1: As much as I've researched and found there is no specific way to work with received SMS directly through any programming language.
I'm connecting to a remote mq queue using pymqi. I'm using put method as normal but I would like to know if there are some way to set something symilar as JMSReplyTo on JMS system to get a synchronous response of my message.
The request queue and the response are created in the remote mq where I'm connecting.
Yes you can set ReplyToQ (JMSReplyTo) and No, there is no one-call function for getting synchronous response.
Look example page or example in source
Is short:
# Prepare a Message Descriptor for the request message.
md = pymqi.MD()
md.ReplyToQ = dyn_queue_name
# Send the message.
queue = pymqi.Queue(qmgr, request_queue)
queue.put(message, md)
Utilizing Twilio, upon receiving any SMS I'm seeking to trigger a Python function that reads the contents of the message, then conditionally performs an action.
I'm referencing from Twilio docs right now (.py):
# Download the helper library from https://www.twilio.com/docs/python/install
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)
message = client.messages('MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch()
print(message.to)
Does anyone know how to automatically set up a trigger OnReceive?
The example you show fetches a known message (a message that has already been received and you know its ID).
In order to have a script that is triggered by incoming message you need to setup a webhook and you need to have an endpoint (server) where you can pick up a trigger sent to you by twilio (eg at www.yourdomain.com/sms).
You might not be able to do it just from within a raspbery pi connected to the internet. You need to setup a trigger somewhere on a server, store the incoming messages somehow and then one solution would be to keep polling the server from raspberry pi, fetching new messages and clearing the list.
I have the following scenario I would like to implement:
User surfs to our website
User enters a bitcoin address.
A websocket is created to the server, passing the address.
The server registers a callback with Blocktrail
When the callback is triggered (a payment was seen by Blocktrail) we send a message back to the browser.
The page the user is browsing is updated to show the message recieved
I'm using webhooks from the Blocktrail API to "listen" to an event, being the reception of coins on an address.
Now, when the event happens, the API does a POST to my URL. This should send a message to the browser that is connected to my server with socket.io (such as 'payment seen on blockchain')
So the question is,
How can I send a message from a route to a socket using flask-socketio
Pseudo code:
#app.route('/callback/<address>')
def callback(id):
socketio.send('payment seen on blockchain')
#socketio.on('address',address)
def socketlisten(address):
registerCallback(address)
I'm going to describe how to solve this using Flask-SocketIO beta version 1.0b1. You can also do this with the 0.6 release, but it is a bit more complicated, the 1.0 release makes addressing individual clients easier.
Each client of a socket connection gets assigned a session id that uniquely identifies it, the so called sid. Within a socket function handler, you can access it as request.sid. Also, upon connection, each client is assigned to a private room, named with the session id.
I assume the metadata that you receive with the callback allows you to identify the user. What you need is to obtain the sid of that user. Once you have it, you can send your alert to the corresponding room.
Example (with some hand-waving regarding how you attach a sid to an address):
#app.route('/callback/<address>')
def callback(address):
sid = get_sid_from_address(address)
socketio.send('payment seen on blockchain', room=sid)
#socketio.on('address')
def socketlisten(address):
associate_address_with_sid(address, request.sid)
I'm trying to send a subscribe stanza from a (a#gmail.com) to b(b#gmail.com), but the Google Talk XMPP server isn't forwarding the stanza (i.e. b never receives it).
If I log in to Gmail with a#gmail.com and invite b#gmail.com, b#gmail.com does receive the IQ stanza and it looks like this:
<presence xmlns='jabber:client' from='a#gmail.com' type='subscribe' to='b#gmail.com'><sub:invitation xmlns:sub='google:subscribe'><sub:body/></sub:invitation></presence>
[Note that from and to are both just the usernames not the full JID specifying a specific chat resource like a#gmail.com/ABC145D]
If I try to construct a presence stanza like the one b receives when doing it through gmail, I get a 'bad-request' error from the GTalk XMPP server saying:
If set, the 'from' attribute must be set to the user's full JID.
However, if I try a) specifying the full "from" JID, b) leaving the "from" off the stanza entirely, or c) specifying the full JID for "from" and "to", none of them work. GTalk XMPP server does not transmit the presence subscription request from a#gmail.com to b#gmail.com
I got it to work with a stanza of the following form and by also adding the item to the roster (buddy list) before requesting the subscription
<presence xmlns='jabber:client' from='a#gmail.com' type='subscribe' to='b#gmail.com'><sub:invitation xmlns:sub='google:subscribe'><sub:body/></sub:invitation></presence>