HeyWatch API Connection Problem using .NET
i tried a few methods but no one seems to work. look at http://heywatch.com/ and to the API http://wiki.heywatch.com/API+Documentation
Our API is based on REST principles, so what you just have to do is an HTTP request to the right resource and the right describing method. The URL to request is always the same: http://heywatch.com or https://heywatch.com
To use our API, you must be authenticated via Basic Auth.
I have an account and trying to just recieve the simple account information using http://heywatch.com/account.xml.
But no chance. I tried following
Dim req As WebRequest = WebRequest.Create(Url & "account.xml")
req.Headers.Add(HttpRequestHeader.Authorization, "BASIC [USER]:[pass]")
req.Method = "GET"
I replaced the Headers UserPass stuff with Base64 encoded string too
I tried also
Dim myCred As New NetworkCredential(ApiUser, ApiPass, ApiUrl)
Dim credCache As New CredentialCache
credCache.Add(New Uri(ApiUrl), "Basic", myCred)
req.Credentials = credCache
I then later tried to change any possible property like UseDefaultCredentials
or AuthenticationLevel
I always get an 401 Not Authorized Error. Please he开发者_StackOverflowlp, thanks ;-)
BTW.: There is already a ported version to PHP, https://github.com/madewithlove/php-heywatch-class
Seems like i made something stupidly wrong yesterday
Dim req As HttpWebRequest = HttpWebRequest.Create(url)
req.Method = "GET"
req.Headers.Add("Authorization", "Basic " & Base64.encrypt(user & ":" & pass))
works perfectly now...
https://github.com/particles/heywatch-dotnet
Is a mostly complete HeyWatch library in C#. It simplifies making requests and handling responses.
精彩评论