LinkedIn - cannot send messages - python

I am using Python API for sending messages in LinkedIn.
I found that
api.SendMessage("This is a test subject", "This is the test body", [pid])
can send messages only to the ones who are in our connected list and not others.
How do you send messages to anyone who is not in our connect list?

As I answered elsewhere, this is how LinkedIn behaves, whether you use the API or not. You can only message first degree connections.
There is an InMail feature that allows for messaging outside your first degree network, but that is a paid product. Is that something you're interested in?
Or the other option is to have a person between the sending and recipient agree to "pass the message along." That is not available via the API, however.
That's all I say here, as we're now outside the scope of technical questions.

Related

How to send chat messages to individuals by email address using Google Chat API?

Some Context
So, I'm developing a task that analyzes several groups of data from a website and then sends a notification to the person who is tied to that group of data. From the groups of data, we are able to retrieve the person's email address as well as their name and some other personal identifying information.
The Goal
All of these users are part of a the same Google group. What we'd like to do is send them (the individual user tied to the data group) the notification and relevant data as a Google Chat message—their primary form of communication.
What I Understand
The Google Chat API seems to have some cool HTTP API requests available for the purpose of chatbots, but after searching around and viewing their references, it seems that this API is not used as anything more than as a chatbot or similar. It seems to need webhooks or some sort of account ID in order to create a message to someone in particular.
The Question
So, my question is as to whether or not there is a way to use the Google Chat API to send a message to a particular individual in the workspace identified by their email address.
My particular instance uses python, but if there were code/concepts in another language or whatever, please share. Thanks!
I think you may find this other post useful. You are pretty much correct about how the API works. As described in the official documentation about the Google Chat API, everything is done using bots.

Sending emails through python

I wish to setup a subscribe form. The user will fill his/her email address and on submit an email should be sent to the provided email address for verification. The verification email will have a link on which the user can click to verify the email address.
This form will be in a website which I plan to host at Bluehost.
I read this tutorial about how it can be done in Python. Following is a snippet from the tutorial
import smtplib
s = smtplib.SMTP(host='your_host_address_here', port=your_port_here)
s.starttls()
s.login(MY_ADDRESS, PASSWORD)
My question is will I able to make this work on Bluehost ?,
My understanding is that host and port can be obtained as described
in this link.
Also,is there any third-party service that allows me create such subscribe form as described above?
While this could technically work, I highly recommend using a third-party service to send the actual emails. These days, the chance of your email getting delivered if it's being sent from a random Bluehost server is quite low due to its low "email sender reputation".
Snippet from this link explaining it:
An email sender reputation is a score that an Internet Service Provider (ISP) assigns to an organization that sends email. It’s a crucial component of your email deliverability. The higher the score, the more likely an ISP will deliver emails to the inboxes of recipients on their network. If the score falls below a certain threshold, the ISP may send messages to recipients’ spam folders or even reject them outright.
Some email sending services include SendGrid or Amazon SES.
If your website is static, then please go for third party service beacuse it will be difficult for you to handle the backend and integration part. So, look for some third party applications to do it for you for example SendPulse
If your website is dynamic, i.e if its having some backend server part as well, then this email sending part can be done easily depending upon which language you are using at backend. Most languages has support for sending emails.

What are the possible ways to authenticate user when websocket connection is used?

Example scenario: Web based multi-user chat application through websocket connection. How can I ensure (or guarantee) that each connection in this application belongs to certain authenticated user and "can't be" exploited by false user impersonation or intervene during the connection.
by the way I am using tornado websocket on server side to implement basic chat room and already doing authentication for the non-websocket part of my app.
ps : suppose authenticated user posts what he wants and when other user open the listing page of item and automatically other user is added to list of websocket listeners what I want each user able to chat with buyer of the item individually not in a chatroom way but with one to one chat
First and foremost, there are two things you should remember about WebSockets: (a) it's an evolving standard and (b) it is designed with the intention of working with untrusted clients.
The biggest and most important thing you should always do with WebSockets is check their origin. If the origin is mismatched, obviously you don't want to deal with that client, so ignore their requests. Additionally, make sure you're using the "wss" secured WebSocket protocol rather than the "ws" unsecured protocol. This will ensure that your messages are encrypted.
The problem with just doing this, is that this information can be spoofed. See this blog post for a quick demonstration of this.
Additional Security:
Try sending a salted token, having it salted/hashed and sent back and validated in the handshake phase.
Limit requests that happen too frequently (just like the IRC protocol). If the user has submitted 10 lines or more within the span of a second, ignore that user.
Do a quick spam-check (there are lots of algorithms for this) -- stick to light heuristics, otherwise it will burden your server. Things like the presence of the words "free" or "viagra". Give the user a score that represents the likelihood that they are spamming or are a bot. When that is breached, boot them from the servers.
Hope that helps! Sorry if it doesn't. This is my frist answer on StackOverflow. :P
I'm pretty sure the websocket connection sends up any cookies that have been established in the non-websocket connection to your app. You should be able to query Django's session store for the connection's cookie and determine the user that socket belongs to.
Check out: https://docs.djangoproject.com/en/1.3/topics/http/sessions/#configuring-the-session-engine
This is the whole purpose of websocket connection. You authenticate them by handshaking protpcol. For further info see here:
https://datatracker.ietf.org/doc/html/draft-ietf-hybi-thewebsocketprotocol-08

Determine if an XMPP user is online or not

I'm using the xmpppy library to write an XMPP client that can chat with users. It has its own XMPP user account and needs to know if a given user is online. However, the documentation is a bit sparse on how to do this. What would you recommend?
The only solution I've seen thus far is to start up a daemon before the XMPP server starts and monitor all presence messages that are sent out - then a user is said to be online if they've sent the "I'm online"-type message but not the corresponding "I'm logging off" message. However, being new to XMPP in general, I would think there would be a nicer way to do this.
The simple way is to support "subscribe" presence message -- this lets another user check if you're currently present (if they don't already know) by a "subscribe" attempt. Check this useful guide to get started, and the standard for many more important details (esp. on protecting your privacy, if needed, from subscribe requests from user you don't know).
There are basically three ways to connect to an XMPP server: as a client (which you've done), as a component, and as another server. The server-to-server type (s2s) is just a federated connection, very much like how mail servers exchange email with each other.
Alex described how clients keep track of presence. XMPP requires me to approve that you can receive my presence information and vice versa. For your bot this means for you to keep track of who's online the end users need to accept your presence requests. It also means that you can respond to the user's presence requests and keep them informed about if your bot is up or not.
The last way is as a trusted component, and only works if you're running the server. i.e. if you're trying to do this on the jabber.org server, you're out of luck, because you're not running that server. The upsdie is you can have access to the internals of the XMPP server, like pulling lists of everyone who's online. The downside is your component / bot implementation is going to be different for every server implementation.

How can I get a response with XMPP client in Python

I'm using XMPP in Python, and I can send messages, but how can I receive?
I must register a handler and process:
def messageCB(sess,mess):
print 'MESSAGE'*100
nick=mess.getFrom().getResource()
text=mess.getBody()
#print mess,nick
print text
client.RegisterHandler('message',messageCB)
while 1:
client.Process(1)
Good post. I notice this code snippet is also in the logger example in xmpppy sourceforge website.
I wonder if it is possible to reply to incoming messages. The code above only receives and the nickname resource ID does not indicate who the sender is (in terms of JID format, user#server) unless xmpppy can translate that appropriately. So how might one take the received message nd "echo" it back to the sender? Or is that not easily possible with the xmpppy library and need to find a different XMPP library?

Categories