当您转到SoundCloud中的用户个人资料并选择连接时,您可以控制上传新声音时自动发布的内容。
我正在创建一个C#应用程序,我希望能够管理这些设置,但是在这种情况下文档没有多大帮助。使用fiddler我能够看到,例如,如果我尝试启用自动发布新声音,则执行以下POST:
POST http://soundcloud.com/connect/twitter/<connection_id_here> HTTP/1.1
Referer: http://soundcloud.com/settings/connections
Content-Type: application/x-www-form-urlencoded
X-Requested-With: XMLHttpRequest
Accept: */*, */*, application/json, text/javascript, soundcloud/json
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; MASEJS; rv:11.0) like Gecko
Host: soundcloud.com
Content-Length: 158
DNT: 1
Connection: Keep-Alive
Pragma: no-cache
Cookie: <huge_cookie_info_here>
_method=put&authenticity_token=<auth_token_here>&external_identity%5Bpost_tracks%5D=1&external_identity%5Bpost_favorites%5D=0
我试图在没有成功的情况下复制上面的代码。这就是我正在做的事情:
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("_method","put"),
new KeyValuePair<string, string>("authenticity_token","<auth_token_here>"),
new KeyValuePair<string, string>("external_identity[post_tracks]","1"),
new KeyValuePair<string, string>("external_identity[post_favorites]","0"),
});
var client = new HttpClient();
var response = await client.PostAsync("http://soundcloud.com/connect/twitter/<connection_id_here>", content);
即使响应状态为OK,连接设置也保持不变。
有人愿意帮忙吗?
此致
爱德华多塞拉诺