• <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 放屁阿狗 閱讀(919) 評論(0)  編輯 收藏 引用 所屬分類: perl/python/php/lua/tclWebService
            亚洲中文久久精品无码| 久久精品极品盛宴观看| 国内精品久久久久久野外| 伊人丁香狠狠色综合久久| 漂亮人妻被中出中文字幕久久| 99久久国产综合精品麻豆| 久久精品免费全国观看国产| 亚洲乱码精品久久久久..| 日韩久久无码免费毛片软件| 久久久精品国产sm调教网站| 久久热这里只有精品在线观看| 久久人人爽人人精品视频| 久久综合久久综合久久| 99久久久精品免费观看国产| 久久水蜜桃亚洲av无码精品麻豆 | 亚洲乱码日产精品a级毛片久久| 久久精品国产亚洲AV高清热| 久久se精品一区精品二区国产| 久久免费美女视频| 一级做a爰片久久毛片看看| 久久99精品国产99久久6男男| 久久久精品久久久久久| 日韩美女18网站久久精品| 国产精品久久久亚洲| 99久久做夜夜爱天天做精品| 国产成人综合久久精品尤物| 色婷婷久久综合中文久久一本| 久久国产高清字幕中文| 狠狠色狠狠色综合久久| 欧美国产精品久久高清| 国产一区二区精品久久凹凸| 青青青国产成人久久111网站| 久久久久久午夜成人影院 | 麻豆精品久久久久久久99蜜桃| 久久精品国产69国产精品亚洲| 久久精品国产亚洲av高清漫画| 久久久久人妻一区二区三区 | 久久综合亚洲欧美成人| 久久综合亚洲鲁鲁五月天| 偷偷做久久久久网站| 精品久久久久久无码中文野结衣|