Пример #1
0
    def do(self, text, link):
        config = get_config()
        access_token = config.get('facebook', 'access_token')
        graph = facebook.GraphAPI(access_token)

        attachment = {'link': link}
        response = graph.put_wall_post(message=text, attachment=attachment)
Пример #2
0
    def do(self, text, link):
        config = get_config()
        relayer = config.get('relayer', 'url')
        username = config.get('relayer', 'username')
        result =  requests.post(relayer,
		     {"user_name": username,
                      "text": text, "link":link})
        return("OK")
Пример #3
0
    def do(self, text, link):
        config = get_config()
        access_token = config.get('facebook', 'access_token')
        graph = facebook.GraphAPI(access_token)

        attachment = {
            'link': link
        }
        response = graph.put_wall_post(message=text, attachment=attachment)
Пример #4
0
    def do(self, text, link):
        config = get_config()
        oauth_token = config.get('twitter', 'token')
        oauth_secret = config.get('twitter', 'secret')
        body = self.create_body(text, link)

        twitter = Twitter(auth=OAuth(oauth_token, oauth_secret,
                                     TWITTER_CONSUMER_KEY,
                                     TWITTER_CONSUMER_SECRET),
                          api_version='1.1',
                          domain='api.twitter.com')

        twitter.statuses.update(status=body)
Пример #5
0
    def do(self, text, link):
        config = get_config()
        oauth_token = config.get('twitter', 'token')
        oauth_secret = config.get('twitter', 'secret')
        body = self.create_body(text, link)

        twitter = Twitter(
            auth=OAuth(
                oauth_token, oauth_secret,
                TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET),
            api_version='1.1',
            domain='api.twitter.com')

        twitter.statuses.update(status=body)
Пример #6
0
    def submit_share(self, comment):
        config = get_config()
        access_token = config.get('linkedin', 'access_token')
        company_id = config.get('linkedin', 'company_id')
        post = {
                'comment': comment,
                'visibility': {
                    'code': 'anyone'
                }
            }
        url = COMPANY_URL.format(company_id)

        try:
            response = self._make_request('POST', url, access_token,
                                         data=json.dumps(post))
            response = response.json()
            return response
        except Exception as err:
            print err
            return False
Пример #7
0
    def get_access_token(self):
        config = get_config()
        client_id = config.get('linkedin', 'client_id')
        client_secret = config.get('linkedin', 'client_secret')
        return_url = config.get('linkedin', 'return_url')

        permissions = ['r_basicprofile', 'w_share', 'rw_company_admin']
        authentication = linkedin.LinkedInAuthentication(client_id, client_secret,
                                                         return_url,permissions)
        app = linkedin.LinkedInApplication(authentication)
        print '**************************************\n'
        print '  PROCESS TO OBTAIN THE ACCESS_TOKEN  \n'
        print '**************************************\n'

        print '\nCopy and then open this URL on your browser: \n' + authentication.authorization_url
        print '\nThen login and paste the CODE \n'
        # TODO: Listen RETURN_URL parameter and look for the arg code
        # An error can ocurr, in that case, set the autorization_code variable

        authentication.authorization_code = raw_input('Input CODE: ')
        token = authentication.get_access_token()
        print '\nACCESS_TOKEN:\n ' + str(token)
        save_to_config('linkedin', 'access_token', token.access_token)
        print '\n(By default is valid for 60 days only.)'
Пример #8
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import cgi
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer

from socialbot.utils import get_config

config = get_config()
MAGIC_KEYWORD = config.get('main', 'magic_keyword')


class SlackBotHandler(BaseHTTPRequestHandler):
    def _check_is_valid(self, url):
        return True

    def _sanitize(self, url):
        return url

    def do_POST(self):
        content_len = int(self.headers.getheader('content-length', 0))
        post_body = self.rfile.read(content_len)
        payload = None
        user_name = None
        try:
            postvars = cgi.parse_qs(post_body, keep_blank_values=1)
            user_name = postvars.get('user_name')[0]
            content = postvars.get('text')[0]
            has_pipe = content.find("|")
            has_less = content.find("<")
            if has_pipe != -1 or has_less == -1:
                raise Exception("Invalid Link format")
Пример #9
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import cgi
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer

from socialbot.utils import get_config

config = get_config()
MAGIC_KEYWORD = config.get('main', 'magic_keyword')


class SlackBotHandler(BaseHTTPRequestHandler):

    def _check_is_valid(self, url):
        return True

    def _sanitize(self, url):
        return url

    def do_POST(self):
        content_len = int(self.headers.getheader('content-length', 0))
        post_body = self.rfile.read(content_len)
        payload = None
        user_name = None
        try:
            postvars = cgi.parse_qs(post_body, keep_blank_values=1)
            user_name = postvars.get('user_name')[0]
            content = postvars.get('text')[0]
            has_pipe = content.find("|")
            has_less = content.find("<")
            if has_pipe != -1 or has_less == -1:
Пример #10
0
 def do(self, text, link):
     config = get_config()
     relayer = config.get("relayer", "url")
     username = config.get("relayer", "username")
     result = requests.post(relayer, {"user_name": username, "text": text, "link": link})
     return "OK"