• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            socketref,再見!高德

            https://github.com/adoggie

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              246 Posts :: 4 Stories :: 312 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(54)

            我參與的團隊

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜


            訪問sf,記錄下一下代碼

            (注冊sf的app,登記 callback-url,執行sql查詢)
            #coding:utf-8
            __author__ = 'scott'
            import imp
            imp.load_source('init','../init_script.py')
            import urllib2,urllib,json,sys,os
            import traceback,threading,time,struct,os,os.path,shutil,distutils.dir_util,array,base64,zlib,struct,binascii
            import datetime
            from libs.python.lemon import webapi
            callback = 'http://localhost:8002/oauth'
            client_id = '3MVG9ZL0ppGP5UrC_wQ8U02mOhowPKwjeaaLsWZ3BcYYVqiSsy1rL_D2h6qG.rGPnb_j6IcgLHPdhmvomzDFj'
            client_secret = '9046731979xxxxxxx'

            def accessToken(request,code,state):
                url = 'https://login.salesforce.com/services/oauth2/token'
                data = {
                    'grant_type':'authorization_code',
                    'code':code,
                    'client_id':client_id,
                    'client_secret':client_secret,
                    'redirect_uri':callback
                }
                result = ''
                try:
                    result = urllib2.urlopen(url,urllib.urlencode(data) )
                except:
                    traceback.print_exc()
                result = result.read()
                return json.loads( result )

            def oauth(request):
                cr = webapi.SuccCallReturn()
                code =  webapi.GET(request,'code','')
                state = webapi.GET(request,'state','')
                cr.result=[code,state]
                token = accessToken(request,code,state)
                cr.result.append(token)
                print token
                try:
                    sqlExecute(token['access_token'],token['instance_url'])
                except:
                    traceback.print_exc()
                return cr.httpResponse()

            import cookielib

            # -H "Authorization: OAuth token" -H "X-PrettyPrint:1" "
            def sqlExecute(token,url_host):
                httpHandler = urllib2.HTTPHandler(debuglevel=1)
                httpsHandler = urllib2.HTTPSHandler(debuglevel=1)
                opener = urllib2.build_opener(httpHandler, httpsHandler)
                urllib2.install_opener(opener)
                sf_cmd_query="%s/services/data/v20.0/query/?%s"%(url_host, urllib.urlencode({'q':'select count() from account'}))
                headers = {
                    'Authorization':'OAuth %s'%token,
                    'X-PrettyPrint':1
                }
                httpReq = urllib2.Request( sf_cmd_query,headers=headers )
                r = opener.open(httpReq).read()
                print r
                pass

            url1 = """https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=%s&redirect_uri=%s&state=first"""%(client_id,callback)

            def launchBrowserForOAuth():
                import webbrowser
                webbrowser.open(url1)

            if __name__ == '__main__':
                launchBrowserForOAuth()
            posted on 2015-06-29 20:21 放屁阿狗 閱讀(924) 評論(0)  編輯 收藏 引用 所屬分類: perl/python/php/lua/tclWebService
            久久国产视屏| 久久99精品久久只有精品| 久久久青草青青亚洲国产免观| 97超级碰碰碰久久久久| 伊人久久大香线蕉精品| 亚洲国产成人久久一区久久| 亚洲国产精品一区二区三区久久 | 国产美女久久精品香蕉69| 久久精品国产亚洲77777| 91麻精品国产91久久久久| 一级女性全黄久久生活片免费| 99精品国产在热久久无毒不卡 | 国产免费福利体检区久久| 久久天天躁狠狠躁夜夜avapp| 国产精品99久久免费观看| 性做久久久久久久久浪潮| 青青青国产精品国产精品久久久久| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区| 亚洲AV成人无码久久精品老人| 久久国产福利免费| 久久99国产精品一区二区| 亚洲综合精品香蕉久久网| 久久人人添人人爽添人人片牛牛| 国产精品99久久久久久董美香| 91精品国产乱码久久久久久| 超级97碰碰碰碰久久久久最新| 久久久久国产精品嫩草影院| 国产成人精品久久亚洲高清不卡| 久久精品国产亚洲AV大全| 香蕉久久夜色精品升级完成 | 久久久久久毛片免费播放| 麻豆久久久9性大片| 久久无码一区二区三区少妇| 久久久青草青青国产亚洲免观| 国产激情久久久久影院老熟女免费 | 日本精品久久久久中文字幕8| 久久亚洲精品中文字幕| 久久综合国产乱子伦精品免费| 亚洲va中文字幕无码久久不卡| 久久综合狠狠综合久久综合88| 久久精品国产亚洲AV嫖农村妇女|