Smugmug API with oAuth + .NET
dlado
Registered Users Posts: 11 Big grins
Hi All,
I'm developing a proxy in .NET that uses Smugmug API to retreive albums data. One of the requirements is to use oAuth.
I implemented all the logic that gets the token but I'm not being able to call any methods using HttpWebRequest
I'd like to know whic URL I should use to call, for example, smugmug.albums.get. I prefare not to use JSON, I'd like to use XML-RPC as a response.
I checked this URL http://wiki.smugmug.net/display/API/show+1.2.2?method=smugmug.albums.get but I'm not understanding how I could call them.
The code looks like (finalGetUrl is the variable that has the URL I don't know what should have there):
HttpWebRequest webRequest = null;
webRequest = System.Net.WebRequest.Create(finalGetUrl) as HttpWebRequest;
webRequest.ContentType = "text/xml";
webRequest.Method = method;
webRequest.Credentials = CredentialCache.DefaultCredentials;
webRequest.AllowWriteStreamBuffering = true;
webRequest.PreAuthenticate = true;
webRequest.ServicePoint.Expect100Continue = false;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
webRequest.Headers.Add("Authorization", "OAuth realm=\"http://api.smugmug.com/\",oauth_consumer_key=\"" + this.ConsumerKey + "\",oauth_token=\"" + this.Token + "\",oauth_signature_method=\"HMAC-SHA1\",oauth_signature=\"" + HttpUtility.UrlEncode(sig) + "\",oauth_timestamp=\"" + timeStamp + "\",oauth_nonce=\"" + nonce + "\",oauth_verifier=\"" + this.Verifier + "\", oauth_version=\"1.0\"");
string returned = WebResponseGet(webRequest);
I'm developing a proxy in .NET that uses Smugmug API to retreive albums data. One of the requirements is to use oAuth.
I implemented all the logic that gets the token but I'm not being able to call any methods using HttpWebRequest
I'd like to know whic URL I should use to call, for example, smugmug.albums.get. I prefare not to use JSON, I'd like to use XML-RPC as a response.
I checked this URL http://wiki.smugmug.net/display/API/show+1.2.2?method=smugmug.albums.get but I'm not understanding how I could call them.
The code looks like (finalGetUrl is the variable that has the URL I don't know what should have there):
HttpWebRequest webRequest = null;
webRequest = System.Net.WebRequest.Create(finalGetUrl) as HttpWebRequest;
webRequest.ContentType = "text/xml";
webRequest.Method = method;
webRequest.Credentials = CredentialCache.DefaultCredentials;
webRequest.AllowWriteStreamBuffering = true;
webRequest.PreAuthenticate = true;
webRequest.ServicePoint.Expect100Continue = false;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
webRequest.Headers.Add("Authorization", "OAuth realm=\"http://api.smugmug.com/\",oauth_consumer_key=\"" + this.ConsumerKey + "\",oauth_token=\"" + this.Token + "\",oauth_signature_method=\"HMAC-SHA1\",oauth_signature=\"" + HttpUtility.UrlEncode(sig) + "\",oauth_timestamp=\"" + timeStamp + "\",oauth_nonce=\"" + nonce + "\",oauth_verifier=\"" + this.Verifier + "\", oauth_version=\"1.0\"");
string returned = WebResponseGet(webRequest);
0
Comments
Our endpoints are listed here.
So the XML-RPC endpoint for API 1.2.2 is... http://api.smugmug.com/services/api/xmlrpc/1.2.2/
Therefore to call smugmug.albums.get, you need to add the method parameter and any of the other required parameters..
http://api.smugmug.com/services/api/xmlrpc/1.2.2/?method=smugmug.albums.get
Let me know if you have any questions.
Cheers,
David
SmugMug API Developer
My Photos
I had to call the URL you sent me and then add the arguments needed for oAuth (oauth_token, etc)
Cheers