• <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 放屁阿狗 閱讀(927) 評論(0)  編輯 收藏 引用 所屬分類: perl/python/php/lua/tcl 、WebService
            久久精品免费全国观看国产| 久久国产欧美日韩精品| 精品久久国产一区二区三区香蕉 | 岛国搬运www久久| 色欲综合久久躁天天躁| 国产免费久久精品99re丫y| 久久亚洲日韩精品一区二区三区 | 亚洲国产天堂久久久久久| 久久综合亚洲色HEZYO社区| 99久久精品国产麻豆| 日本高清无卡码一区二区久久| 精品国产青草久久久久福利| 久久久久久狠狠丁香| 久久久久久久精品妇女99| 国产午夜精品理论片久久| 久久综合给合久久国产免费 | 99久久国产综合精品网成人影院| 久久AV无码精品人妻糸列| 91精品国产高清久久久久久91| 久久久久久久久久久| 久久伊人中文无码| 夜夜亚洲天天久久| 精品一区二区久久久久久久网站| 怡红院日本一道日本久久| 久久无码人妻一区二区三区午夜| 亚洲七七久久精品中文国产| 久久精品二区| 无码8090精品久久一区| 久久91精品综合国产首页| 蜜桃麻豆www久久| 青青青青久久精品国产| 精品九九久久国内精品| 国产亚洲精久久久久久无码 | 久久中文字幕无码专区| 国产精品免费久久| 精品久久久久久无码人妻蜜桃 | 久久香蕉综合色一综合色88| 国产精品久久久久AV福利动漫| 人人狠狠综合久久88成人| 久久久免费精品re6| 99久久综合狠狠综合久久止|