如何使用Python訪問37個信號Highrise的API?發現PHP/Ruby的包裝,但不是Python。我正在寫我自己的,任何人都有關於通過Python認證的第一個障礙的建議?使用Python訪問Highrise的API?
0
A
回答
4
我寫了(正在編寫,真的)一個Python的Highrise API包裝器。它使用Python對象爲每個高層類和工作帶來很多喜歡Django的ORM:一封來自PyPI https://github.com/feedmagnet/pyrise
或者安裝:
>>> from pyrise import *
>>> Highrise.server('my-server')
>>> Highrise.auth('api-key-goes-here')
>>> p = Person()
>>> p.first_name = 'Joe'
>>> p.last_name = 'Schmoe'
>>> p.save()
你可以從GitHub獲得源
$ sudo pip install pyrise
0
我只是在尋找php API wrappers之一的php代碼,我發現它們使用了捲曲;所以你看看pycurl ??
對這裏的認證,您可以使用啓動一個例子(它未測試)...
import pycurl
def on_receive(data):
# process your data here
pass
def connetion(url, token)
conn = pycurl.Curl()
# Set Token.
conn.setopt(pycurl.USERPWD, "%s:x" % (token,))
# the format TOKEN:x i get it from the PHP wrapper because usually the
# format should be USER:PASSWD so here i think they just use a token as
# a USERname and they set the password to 'x'.
conn.setopt(pycurl.URL, url)
# Set the XML data to POST data.
conn.setopt(pycurl.POSTFIELDS, XML_DATA)
# Add SSL.
conn.setopt(pycurl.SSL_VERIFYPEER, 0)
conn.setopt(pycurl.SSL_VERIFYHOST, 0)
# Set function that will be called as soon as the data is received.
conn.setopt(pycurl.WRITEFUNCTION, on_receive)
# Perform the data transfer.
conn.perform()
if __name__ == '__main__':
connection("http://yourcompany.highrisehq.com", your_token)
0
參見如何做到基本身份驗證here。另外IIRC urllib支持http://user:[email protected]
網址。
1
當我偶然發現你的問題時,我只是解決了這個問題。這是我迄今爲止一起入侵的內容。它不漂亮(但),但它的作品。我不知道Pycurl,看了一會之後,我回到了urllib2。 Highrise使用基本身份驗證,因此您不必使用CURL即可使用urllib2。你只需要通過所有的Pword Manager步驟。輸出是所有公司或人員的長XML文件,具體取決於您插入的URL。如果你只想要一個人,你可以做'http ....../people/123.xml'或'http ....../people/123-fname-lname.xml'(就像你看到的那樣在URL中,當你實際上去了高層的聯繫人,添加了.xml)。
import ullib2
PEOPLEurl = 'http://yourcompany.highrisehq.com/people.xml' #get all the people
# or
COMPANYurl = 'http://yourcompany.highrisehq.com/company.xml' #get all companies
token = '12345abcd' #your token
password = 'X'
passmanager = urllib2.HTTPPasswordMgrWithDefaultRealm()
passmanager.add_password(None, PEOPLEurl, token, password)
authhandler = urllib2.HTTPBasicAuthHandler(passmanager)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
page = urllib2.urlopen(PEOPLEurl).read()
print page #this will dump out all the people contacts in highrise
上任何意見或建議,這代碼將是有益的!
相關問題
- 1. Highrise API用戶名問題
- 2. 使用Highrise API包裝
- 3. 訪問API使用Python
- 4. 使用Python訪問API
- 5. 37signals Highrise .NET(c#)API
- 6. 使用Python的Google日曆API訪問
- 7. Highrise API示例。幫助
- 8. 如何使用Python訪問Flickr API?
- 9. 使用Python訪問Power BI API
- 10. 使用Python API中的IAM角色訪問AWS API網關
- 11. 訪問使用python
- 12. Highrise API - 如何使用XML並操作變量
- 13. Ruby/Highrise API - 不保存電話號碼?
- 14. 使用Nodejs訪問Google Api
- 15. 使用AJAX訪問Twitter API
- 16. 使用JQuery訪問Twitter API
- 17. 使用R訪問API
- 18. Python |訪問DLL使用ctypes
- 19. 使用Python訪問MySQL
- 20. 使用Oauth使用Javascript訪問Api
- 21. 使用WebSphere的API來訪問OperatingSystem的
- 22. 使用Android的Gmail API訪問
- 23. 使用DotNetOpenAuth訪問Yelp的OAuth 1.0a API
- 24. 使用訪問令牌的Android Dropbox API v2自動訪問
- 25. 使用Suds訪問Atlassian人羣SOAP API(python SOAP庫)
- 26. 如何使用Java(而不是python)訪問API URL?
- 27. 使用Google API在Python中訪問電子表格
- 28. Rest API驗證和訪問使用Python請求
- 29. 使用Python API訪問Google Analytics自定義報告
- 30. 如何使用JIRA -REST-API for python訪問下一頁
pyrise是一個很好的API封裝器,雖然它依賴於使用* now *過期SSL證書的httplib2,並且默認情況下會出錯 - 您需要從geotrust更新httplib2 cacerts.txt文件 - http:///www.geotrust.com/resources/root_certificates/certificates/GeoTrust_Global_CA.c呃 – Alvin 2012-03-15 00:53:03