How to use Python and Mailchimp to send an email? - python

I have been reading a lot on the Internet to know how I can use Python to send emails using mailchimp API. It seems that the website is so complected and doesn't have any example.
Please, could you guide me to any example including a Python use?
What I tried so far:
I installed the library from pip using:
pip install mailchimp;
I have created the campain;
I have created the lists;
But yet, I couldn't know how to send the emails programmatically.

If you want to trigger a campaign see:
https://apidocs.mailchimp.com/api/2.0/campaigns/send.php
The typical module mailchimp at pypi supports it as followed.
from mailchimp import Mailchimp
mailchimp = Mailchimp(api_key)
mailchimp.campaigns.send(campaign_id)
Sourcecode at: https://bitbucket.org/mailchimp/mailchimp-api-python/src/32ed2394d6b49d7551089484221fa3ee019bee37/mailchimp.py?at=master
Hope it helps.
Cheers,
mrcrgl

Related

Using the Tumblr API

It's something new for me working with API, but I really want to create something good. Maybe somebody of you've already worked with Tumblr API (not necessary with Tumblr, it can be Twiter or something else ) and could show me the simplest examples of retrieving of some data.
P.S: I've read the documentation of using API but I don't know how it works and what I should do to get the data. So if you can, I'll be very happy.
I was advised to use a Tumblr client, but now there is new question. How to install and how to use it in my own code?
You can use the official Tumblr client
If you want to write a client from scratch take a look in requests library.
A simple GET request will be something like this requests.get('https://api.github.com/user')
Use pip to install python packages.
After installing... From the shell, run:
pip install pytumblr
or
pip3 install pytumblr

Pulling Google Drive into Command Line

Struggling to finish building out a python script intended to pull a few lines of text from 3 different columns in a Google spreadsheet.
When I run the script, I get the following error message:
File "pr_email_robot.py", line 2, in <module>
import gspread
ImportError: No module named gspread
Pats-MacBook-Pro:pr-email-robot-master patahern$
The area of code that must be off is:
import smtplib
import gspread
from gmail_variables import *
gc = gspread.login(GMAIL_USERNAME, GMAIL_PASSWORD)
wks = gc.open("PR-Command-Line-Emails").sheet1
recipients = wks.get_all_values()
I'm guessing that I have the wrong terminology to pull the Google Spreadsheet, but I can't find anything online about what to put in place of "gspread"
Thanks in advance for your help!
Have you tried using Google Fusion Tables (still in beta)? You can query Google Fusion Tables' Rest API using SQL syntax and urllib's urllib.request.urlopen() to issue GET and POST requests. If you are heart set on using Google Sheets, the Google Sheets API looks like it functions in much of the same way as Google Fusion Tables REST API. Meaning, you can still use the built in urllib Python library to issue GET and POST requests to the Sheets API.
It may also be helpful to note that Google has posted a Getting Started in Python Guide for the Google Sheets API. The example shown there, has no mention of any "gspread" imports.
You need to make sure you have the gspread module installed somewhere your Python installation will find it.
If you have pip:
pip install gspread
will make sure that it's installed.
ALSO
Gspread no longer supports using email/login for authentication, and relies on OAuth2 for authentication.
Check out how to set that up here.
Then check out the gspread docs for how to access info from your sheet!

How to get github repo notification using python script?

I have to build a python script which will use to get the notification related to a github repo which contents pull notification, comments, merge to master status etc. After searching I got PyGithub library. but did not get how to make a call and get response in python. Please suggest how to do this using PyGitHub library? Thanks in advance !!!!

Workarounds to get Google sign-in functioning with Python 2.6 and pyOpenSSL 0.10-2

I'm trying to get Google sign-in working using their Python API but the server I'm on (4UHosting) has Python 2.6 and pyOpenSSL 0.10-2 (5-years old).
This means that the API's call to OpenSSL.crypto.verify() fails as it doesn't exist in this version.
I can't install these myself, even --self as they require compiler use which I don't have. The admins are reluctant to install any updates that are not vetted. They won't install pyOpenSSL or Python 2.7 locally just for me. I can't find documentation from pyOpenSSL 0.10-2 that would have an equivalent function to verify().
I'm looking for some suggestions as where to head from here.
Any suggestions would be greatly appreciated,
Cyrille
A few ideas:
You could directly make your API calls to the Google API Endpoints instead of using the Python client library, for example, the token info endpoint can be used to verify tokens
You could do sign-in operations client-side and transfer data to your server once a session is attached
You could use another language (e.g. Ruby) for the sign-in operations

How can I send an iCalendar email attachment with Django?

I want to send an iCalendar http://en.wikipedia.org/wiki/ICalendar email attachment using Django. Is there an open source library to build an iCalendar file in Python and/or available for Django?
As stated before, there is vobject, that is working fine (I have used it recently).
You can find good information about ical, vobject and django in this blog post :
http://blog.thescoop.org/archives/2007/07/31/django-ical-and-vobject/
I've used MaxM's icalendar module. It can build and parse iCalendar files.
There's also vobject which was developed for the Chandler project and seems to be more actively maintained. It's also BSD-licensed which might be important for your use case.

Categories