requests.post.json

Here are the examples of the python api requests.post.json taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

116 Examples 7

Example 1

Project: wego Source File: wechat.py
    def get_article_summary(self, begin_date, end_date):
        """
        Get article summary

        :param data:begin_date, end_date
        :return :Raw data that wechat returns.
        """

        data = {
            "begin_date": begin_date,
            "end_date": end_date
        }

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        url = "https://api.weixin.qq.com/datacube/getarticlesummary?access_token=" + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 2

Project: acrcloud-wechat Source File: main.py
Function: get_song_info
def get_song_info(s):
    song_info = cache.get(s)
    if song_info is None:
        l = requests.post("http://music.163.com/api/search/get/",{'s':s,'limit':1,'sub':'false','type':1,'offset':0}, headers={"Referer": "http://music.163.com/"}).json()["result"]["songs"][0]["id"]
        song_info = requests.get("https://music.daoapp.io/api/v1/song?id=%s&type=meta" %l).json()
        song_info["song_url"] = song_info["song_url"]
        song_info["pic_url"] = song_info["pic_url"]
        cache.set(s, song_info, timeout= 72000)
    return song_info

Example 3

Project: wego Source File: wechat.py
    def del_conditional_menu(self, menu_id):
        """
        Delete conditional menus, contain conditional menu.

        :return: Raw data that wechat returns.
        """

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {
            'menuid': menu_id
        }
        url = 'https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token=%s' + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 4

Project: wego Source File: wechat.py
    def get_wechat_servers_list(self):
        """
        Get wechat servers list

        :param data:
        :return: Raw data that wechat returns.
        """

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        url = "https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=" + access_token
        data = requests.post(url).json()

        return data

Example 5

Project: wego Source File: wechat.py
    def add_other_material(self, **kwargs):

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)

        if 'title' in kwargs and 'introduction' in kwargs:
            data = {
                'type': kwargs['type'],
                'description': {
                    'title': kwargs['title'],
                    'introduction': kwargs['introduction']
                }
            }
        else:
            data = {'type': kwargs['type']}

        url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=%s' % access_token
        data = requests.post(url, data=data, files={'media': kwargs['media']}).json()
        return data

Example 6

Project: wego Source File: wechat.py
Function: change_user_group
    def change_user_group(self, openid, groupid):
        """
        Move user to a new group.

        :param openid: User openid.
        :param groupid: Group ID.
        :return: Raw data that wechat returns.
        """

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {
            'openid': openid,
            'to_groupid': groupid
        }
        url = 'https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=%s' + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 7

Project: wego Source File: wechat.py
    def get_user_share(self, begin_date, end_date):
        """
        Get user share

        param data:begin_data,end_date
        return :Raw data that wechat return.
        """
        data = {
            "begin_date": begin_date,
            "end_date": end_date
        }

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        url = "https://api.weixin.qq.com/datacube/getusershare?access_token=" + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 8

Project: tornado-boilerplate Source File: test_server.py
    def test_main(self):
        port = 7869
        def test(cls):
            import time
            time.sleep(.5)
            result = requests.post("http://localhost:%s/auth/login" % port, {}).json()
            self.assertEqual(result["status"], 400)

        thread = TestingThread(target = test)
        thread.start()
        server.main(True, port)
        thread.join()
        thread.errors()

Example 9

Project: instapush-py Source File: instapush.py
Function: notify
    def notify(self, event_name, trackers):
        payload = {'event': event_name, 'trackers': trackers}
        ret = requests.post('http://api.instapush.im/v1/post',
                            headers=self.headers,
                            data=json.dumps(payload)).json()
        return ret

Example 10

Project: docklet Source File: dockletrequest.py
    @classmethod
    def post(self, url = '/', data = {}):
        #try:
        data = dict(data)
        data['token'] = session['token']
        logger.info ("Docklet Request: user = %s data = %s, url = %s"%(session['username'], data, url))

        result = requests.post(endpoint + url, data=data).json()
        # logger.info('response content: %s'%response.content)
        # result = response.json()
        if (result.get('success', None) == "false" and result.get('reason', None) == "Unauthorized Action"):
            abort(401)
        if (result.get('Unauthorized', None) == 'True'):
            session['401'] = 'Token Expired'
            abort(401)
        logger.info ("Docklet Response: user = %s result = %s, url = %s"%(session['username'], result, url))
        return result

Example 11

Project: wego Source File: wechat.py
    def create_limit_str_scene_qrcode(self, scene_str):

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {
            'action_name': 'QR_LIMIT_SCENE',
            'action_info': {
                'scene': {
                    'scene_str': scene_str
                }
            }
        }
        url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s' + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 12

Project: wego Source File: wechat.py
Function: delete_material
    def delete_material(self, media_id):

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {"media_id": media_id}

        url = 'https://api.weixin.qq.com/cgi-bin/material/del_material?access_token=%s' % access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 13

Project: wego Source File: wechat.py
Function: create_group
    def create_group(self, name):
        """
        Create a user group.

        :param name: Group name.
        :return: Raw data that wechat returns.
        """

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {
            'group': {
                'name': name
            }
        }
        url = 'https://api.weixin.qq.com/cgi-bin/groups/create?access_token=%s' + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 14

Project: wego Source File: wechat.py
    def get_variation_number_of_user(self, begin_date, end_date):
        """
        Get variation in number od user

        :param data:begin_date, end_date
        :return:Raw data that wechat returns.
        """

        data = {
            "begin_date": begin_date,
            "end_date": end_date
        }
        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        url = "https://api.weixin.qq.com/datacube/getusersummary?access_token=" + access_token

        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 15

Project: azure-sdk-for-python Source File: create_credentials_file.py
Function: get_token
def get_token(username, password):
    #  the client id we can borrow from azure xplat cli
    client_id = '04b07795-8ddb-461a-bbee-02f9e1bf7b46'
    grant_type = 'password'
    resource = 'https://management.core.windows.net/'
    token_url = 'https://login.windows.net/common/oauth2/token'

    payload = {
        'grant_type': grant_type,
        'client_id': client_id,
        'username': username,
        'password': password,
        'resource': resource,
    }
    response = requests.post(token_url, data=payload).json()
    return response['access_token']

Example 16

Project: wego Source File: wechat.py
    def get_user_read(self, begin_date, end_date):
        """
        Get user read

        :param data:begin_date, end_date
        :return :Raw data that wechat returns.
        """
        data = {
            "begin_date": begin_date,
            "end_date": end_date
        }

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        url = "https://api.weixin.qq.com/datacube/getuserread?access_token=" + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 17

Project: wego Source File: wechat.py
    def create_menu(self, data):
        """
        Create a menu.

        :param data: Menu data.
        :return: Raw data that wechat returns.
        """

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + access_token
        data = requests.post(url, data=json.dumps(data, ensure_ascii=False).encode('utf8')).json()

        return data

Example 18

Project: p.haul Source File: p_haul_web_gui.py
def start_web_gui(migration_partner, _rpc_port, _debug=False):
    global partner
    global myself
    global rpc_port
    rpc_port = _rpc_port
    partner = migration_partner
    if partner:
        try:
            myself = requests.post("http://%s:%d/register" %
                                   (partner, default_port),
                                   data={"partner": partner}
                                   ).json()['your_ip']
        except:
            pass
    APP.run(host='0.0.0.0', port=default_port, debug=_debug, threaded=True)

Example 19

Project: rapidpro Source File: clients.py
    def start_call(self, call, to, from_, status_callback):

        channel = call.channel
        Contact.get_or_create(channel.org, channel.created_by, urns=[URN.from_tel(to)])

        # Verboice differs from Twilio in that they expect the first block of twiml up front
        payload = unicode(Flow.handle_call(call, {}))

        # now we can post that to verboice
        url = "%s?%s" % (self.endpoint, urlencode(dict(channel=self.verboice_channel, address=to)))
        response = requests.post(url, data=payload, auth=self.auth).json()

        if 'call_id' not in response:
            raise IVRException(_('Verboice connection failed.'))

        # store the verboice call id in our IVRCall
        call.external_id = response['call_id']
        call.status = IN_PROGRESS
        call.save()

Example 20

Project: instapush-py Source File: instapush.py
Function: add_event
    def add_event(self, event_name, trackers, message):
        payload = {'title': event_name,
                   'trackers': trackers,
                   'message': message}
        ret = requests.post('http://api.instapush.im/v1/events/add',
                            headers=self.headers,
                            data=json.dumps(payload)).json()
        return ret

Example 21

Project: wego Source File: wechat.py
    def add_permanent_material(self, articles):

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)

        url = 'https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=%s' % access_token

        data = {'articles': articles}
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 22

Project: wego Source File: wechat.py
    def upload_content_picture(self, media):

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)

        url = 'https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=%s' % access_token

        data = requests.post(url, files={'media': media}).json()
        return data

Example 23

Project: chain-api Source File: test_doppel2.py
def post_site(collection_url):
    new_site = {
        'name': 'Test Site %d' % random.randint(0, 1000000)
    }
    response = requests.post(collection_url, data=json.dumps(new_site)).json()
    logger.info('posted new device to %s' % response['_href'])

Example 24

Project: wego Source File: wechat.py
    def get_permanent_material(self, media_id):

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {"media_id": media_id}

        url = 'https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=%s' % access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 25

Project: docklet Source File: dockletrequest.py
    @classmethod
    def unauthorizedpost(self, url = '/', data = None):
        data = dict(data)
        data_log = {'user': data.get('user', 'external')}
        logger.info("Docklet Unauthorized Request: data = %s, url = %s" % (data_log, url))
        result = requests.post(endpoint + url, data = data).json()
        logger.info("Docklet Unauthorized Response: result = %s, url = %s"%(result, url))
        return result

Example 26

Project: wego Source File: wechat.py
    def create_limit_scene_qrcode(self, scene_id):

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {
            'action_name': 'QR_LIMIT_SCENE',
            'action_info': {
                'scene': {
                    'scene_id': scene_id
                }
            }
        }
        url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s' + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 27

Project: wego Source File: wechat.py
    def get_materials_list(self, material_type, offset, count):

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {
            "type": material_type,
            "offset": offset,
            "count": count
        }

        url = 'https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=%s' % access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 28

Project: wego Source File: wechat.py
    def is_access_token_has_expired(sele, openid, access_token):
        """
        Determine whether the user access token has expired

        :param openid: User openid.
        :param access_token: function get_access_token returns.
        :return: Raw data that wechat returns.
        """

        data = {
            'access_token': access_token,
            'openid': openid,
        }
        url = 'https://api.weixin.qq.com/sns/auth'
        data = requests.post(url, params=data).json()

        return data

Example 29

Project: wego Source File: wechat.py
Function: create_short_url
    def create_short_url(self, url):

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {
            'action': 'long2short',
            'long_url': url
        }
        url = 'https://api.weixin.qq.com/cgi-bin/shorturl?access_token=%s' + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 30

Project: chain-api Source File: test_doppel2.py
def post_sensor_data(collection_url):
    new_data = {
        'timestamp': datetime.datetime.now().isoformat(),
        'value': random.random() * 100
    }
    response = requests.post(collection_url, data=json.dumps(new_data)).json()
    logger.info('posted new sensor data to %s' % response['_href'])

Example 31

Project: wego Source File: wechat.py
    def check_personalized_menu_match(self, user_id):
        """
        Check whether personalized menu match is correct.

        :param data:user_id
        :return:Raw data that wechat returns.
        """

        data = {
            "user_id": user_id
        }
        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        url = "https://api.weixin.qq.com/cgi-bin/menu/trymatch?access_token=" + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 32

Project: wego Source File: wechat.py
Function: get_user_groups
    def get_user_groups(self, openid):
        """
        Get all a user groups.

        :return: Raw data that wechat returns.
        """

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {
            'openid': openid
        }
        url = "https://api.weixin.qq.com/cgi-bin/groups/getid?access_token=" + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 33

Project: wego Source File: wechat.py
    def get_user_cuemulate(self, begin_date, end_date):
        """
        GET accuemulation of user

        :param date:begin_date, end_date
        :return:Raw data that wechat returns.
        """

        data = {
            "begin_date": begin_date,
            "end_date": end_date
        }

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        url = "https://api.weixin.qq.com/datacube/getusercuemulate?access_token=" + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 34

Project: junction Source File: explara.py
    def get_ticket_types(self, explara_eventid):
        ticket_types = requests.post(
            self.base_url.format('get-tickets'),
            headers=self.headers,
            data={'eventId': explara_eventid}
        ).json()
        return ticket_types

Example 35

Project: wego Source File: wechat.py
    def get_article_total(self, begin_date, end_date):
        """
        Get article total

        :param data:begin_date, end_date
        :return :Raw data that wechat returns.
        """
        data = {
            "begin_date": begin_date,
            "end_date": end_date
        }

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        url = "https://api.weixin.qq.com/datacube/getarticletotal?access_token=" + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 36

Project: wego Source File: wechat.py
Function: del_group
    def del_group(self, groupid):
        """
        Delete a group.

        :param groupid: Group id.
        :return: Raw data that wechat returns.
        """

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {
            'group': {
                'id': groupid
            }
        }
        url = 'https://api.weixin.qq.com/cgi-bin/groups/delete?access_token=%s' + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 37

Project: wego Source File: wechat.py
    def get_user_read_hour(self, begin_date, end_date):
        """
        Get user read hour

        param data:begin_date, end_date
        return :Raw data that wechat return.
        """
        data = {
            "begin_date": begin_date,
            "end_date": end_date
        }

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        url = "https://api.weixin.qq.com/datacube/getuserreadhour?access_token=" + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 38

Project: piprot Source File: piprot.py
def notify_requirements(email_address, requirements, reset=False):
    """Given and email address, list of requirements and optional reset
    argument subscribes the user to updates from piprot.io. The reset
    argument is used to reset the subscription to _just_ these packages.
    """
    return requests.post(NOTIFY_URL,
                         data=json.dumps({'requirements': requirements,
                                          'email': email_address,
                                          'reset': reset}),
                         headers={'Content-type': 'application/json'}).json()

Example 39

Project: wego Source File: wechat.py
    def get_user_share_hour(self, begin_date, end_date):
        """
        Get user share

        param data:begin_date, end_date
        retur :Raw data that wechat return.
        """
        data = {
            "begin_date": begin_date,
            "end_date": end_date
        }

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        url = "https://api.weixin.qq.com/datacube/getusersharehour?access_token=" + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data

Example 40

Project: wego Source File: wechat.py
    def create_conditional_menu(self, data):
        """
        Create a conditional menu.

        :param data: Menu data.
        :return: Raw data that wechat returns.
        """

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        url = "https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=" + access_token
        data = requests.post(url, data=json.dumps(data, ensure_ascii=False).encode('utf8')).json()

        return data

Example 41

Project: applechecker Source File: stock.py
Function: send_sms
    def send_sms(self, message):
        try:
            response = requests.post(SMS, data={
                'number': self.dest, 'message': message}).json()
            if not response['success']:
                print response['message']
        except gaierror:
            print "Couldn't reach TextBelt"

Example 42

Project: django-waitinglist Source File: trello.py
Function: create_list
    def create_list(self, name, board_id):
        url = "/1/lists?token={0}&key={1}".format(self.token, self.key)
        return requests.post("{0}{1}".format(self.base_url, url), data={
            "name": name,
            "idBoard": board_id
        }).json()

Example 43

Project: instapush-py Source File: instapush.py
Function: add_app
    def add_app(self, title):
        payload = {'title': title}
        ret = requests.post('http://api.instapush.im/v1/apps/add',
                            headers=self.headers,
                            data=json.dumps(payload)).json()
        return ret

Example 44

Project: wego Source File: wechat.py
    def add_temporary_material(self, **kwargs):

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)

        url = 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=%s&type=%s' % (access_token, kwargs['type'])

        data = requests.post(url, files={'media': kwargs['media']}).json()
        return data

Example 45

Project: proxmoxer Source File: https.py
Function: init
    def __init__(self, base_url, username, password):
        response_data = requests.post(base_url + "/access/ticket",
                                      verify=False,
                                      data={"username": username, "password": password}).json()["data"]
        if response_data is None:
            raise AuthenticationError("Couldn't authenticate user: {0} to {1}".format(username, base_url + "/access/ticket"))

        self.pve_auth_cookie = response_data["ticket"]
        self.csrf_prevention_token = response_data["CSRFPreventionToken"]

Example 46

Project: PopClip-Extensions Source File: mstrans.py
    def __get_authentication_token(self, client_id, client_secret):
        auth_args = {
            'client_id': client_id,
            'client_secret': client_secret,
            'scope': 'http://api.microsofttranslator.com',
            'grant_type': 'client_credentials'
        }        
        return requests.post('https://datamarket.accesscontrol.windows.net/v2/OAuth2-13', data=auth_args).json()        

Example 47

Project: django-waitinglist Source File: trello.py
    def setup_board(self, name):
        url = "/1/boards/?token={0}&key={1}".format(self.token, self.key)
        board_data = requests.post("{0}{1}".format(self.base_url, url), data={
            "name": name.encode("utf-8"),
            "prefs_permissionLevel": "org",
            "prefs_selfJoin": "true",
            "idOrganization": self.org_id
        }).json()
        return self.create_list(self.imported_answers_list_name, board_data["id"])["id"]

Example 48

Project: chain-api Source File: test_doppel2.py
def post_device(collection_url):
    new_device = {
        'name': 'Test Device %d' % random.randint(0, 1000000000)
    }
    created_device = requests.post(
        collection_url, data=json.dumps(new_device)).json()
    sensor_collection_url = created_device['sensors']['_href']
    logger.info('posted new device to %s' % created_device['_href'])
    for metric, unit in [('temperature', 'celsius'),
                         ('pressure', 'kPa'),
                         ('setpoint', 'celsius'),
                         ('ambient light', 'lux')]:
        new_sensor = {'metric': metric, 'unit': unit}
        requests.post(sensor_collection_url,
                      data=json.dumps(new_sensor))

Example 49

Project: wego Source File: wechat.py
    def set_user_remark(self, openid, remark):
        """
        Set user remark.

        :param openid: User openid.
        :param remark: The remark you want to set.
        :return: Raw data that wechat returns.
        """

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {
            'openid': openid,
            'remark': remark
        }
        url = 'https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=%s' + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        if 'errcode' in data.keys() and data['errcode'] != 0:
            raise WeChatApiError('errcode: {}, msg: {}'.format(data['errcode'], data['errmsg']))

Example 50

Project: wego Source File: wechat.py
    def create_scene_qrcode(self, scene_id, expire):

        access_token = self.settings.GET_GLOBAL_ACCESS_TOKEN(self)
        data = {
            'expire_seconds': expire,
            'action_name': 'QR_SCENE',
            'action_info': {
                'scene': {
                    'scene_id': scene_id
                }
            }
        }
        url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s' + access_token
        data = requests.post(url, data=json.dumps(data)).json()

        return data
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3