def create_subscription(self): gateway = AfricasTalkingGateway(self.APP_USERNAME, self.API_KEY) # Specify the number that you want to subscribe # Please ensure you include the country code (+254 for Kenya in this case) phoneNumber = "+254711XXXYYY" # Specify your Africa's Talking short code and keyword shortCode = "MyAppShortCode" keyword = "MyAppKeyword" # create checkout token try: checkoutToken = gateway.createCheckoutToken(phoneNumber) except AfricasTalkingGatewayException as e: print "Error generating checkout Token:%s" % str(e) return # create subscription try: response = gateway.createSubscription(phoneNumber, shortCode, keyword, checkoutToken) # Only status Success signifies the subscription was successfully print "Status: %s \n Description: %s" % (response['status'], response['description']) except AfricasTalkingGatewayException as e: print "Error creating subscription:%s" % str(e)