我只是想运行一个使用UGC Web服务发布UGC评论的小原型.
代码示例如下.我收到来自Web服务的403响应,表示我没有被授权使用该服务,所以我认为我需要创建一个身份验证标头?有没有人有任何关于如何使用UGC网络服务发表评论的例子?
string ugcData = "{d\":{\"Content\":\"FROM WEB SERVICE\",\"Status\":2,\"ItemPublicationId\":\"68\",\"ItemId\":\"17805\",\"ItemType\":\"16\",\"Id\":0,\"ModeratedDate\":\"\",\"LastModifiedDate\":\"\",\"CreationDate\":\"\",\"Score\":0,\"Moderator\":\"\",\"User\":{\"Id\":\"DOMAIN%5Cbsmith\",\"Name\":\"Bill Smith\"}\"}";
WebServiceClient ugcCall = new WebServiceClient();
ugcCall.UploadString("/PostData", "POST", ugcData);
Run Code Online (Sandbox Code Playgroud)
MTIA.
约翰
我想知道是否有人可以提供任何指针.我正在尝试从Tridion UGC Web服务返回ItemStats但是在尝试绑定结果时遇到以下错误: -
闭合类型TridionWebUGC.CDS.ItemStat没有相应的LastRatedDate可设置属性.
代码示例如下: -
WebServiceClient ugcCall2 = new WebServiceClient();
Uri uri = new Uri("http://new.ugc.service/odata.svc");
CDS.ContentDeliveryService cds = new CDS.ContentDeliveryService(uri);
var myItemStats = cds.ItemStats.Where(p => p.PublicationId == 68 && p.Id == 17792 && p.Type==16);
Run Code Online (Sandbox Code Playgroud)
我可以毫无问题地获得评论和评分.例如
var myComments = cds.Comments.Where(p => p.ItemId == 17805).OrderBy(p => p.CreationDate);
Run Code Online (Sandbox Code Playgroud)
这只是ItemStats给我一个问题.有人有什么想法吗?
谢谢
约翰
尝试向UGC进行webrequest并使用oAuth进行身份验证时,我遇到了问题.我正在进行网络请求,例如: -
WebRequest wr = WebRequest.Create("http://ugc.service/odata.svc/Ratings(Id=200)");
wr.Headers["authorization"] = "OAuth " + auth;
Run Code Online (Sandbox Code Playgroud)
其中auth是我从access_token.svc返回的令牌.根据文档,从服务返回的令牌应该是这样的: -
HufXeuUt%2FYYElA8SYjJOkUkrXxV9dyXRirmKhjW%2FB%2FU%3D
但是,我从access_token.svc返回的内容更像是: -
{ "的access_token": "的client_id%3dtestuser%26expiresOn%3d1361898714646%26digest%3D%2fW%2fvyhQneZHrm1aGhwOlgLtA9xGWd77hkxWbjmindtM%3D", "expires_in":300}
我已经解析了JSON以提取各种字符串并尝试将这些字符串传递给授权,但无论我尝试什么,我都会在日志中收到错误 - "ERROR OAuth2AccessToken - Digest is wrong." 我应该将授权的哪一部分以及以何种格式传递给授权?
非常感谢
约翰
我知道我可以通过使用以下内容通过UGC Web服务添加评论: -
WebServiceClient ugcCall = new WebServiceClient();
string ugcData = "{ \"d\" :{\"Content\":\"" + comment + "\",\"Status\":2,\"ItemPublicationId\":\"" + PublicationId + "\",\"ItemId\":\"" + itemid + "\",\"ItemType\":\"16\",\"Id\":0,\"ModeratedDate\":\"\",\"LastModifiedDate\":\"\",\"CreationDate\":\"\",\"Score\":0,\"Moderator\":\"\",\"User\":{\"Id\":\"ACME%5Cjbloggs\",\"Name\":\"Joe Bloggs\"}}}";
string result = ugcCall.UploadString("/Comments", "POST", ugcData);
Run Code Online (Sandbox Code Playgroud)
我的问题是添加评级和喜欢和不喜欢的语法是什么?这记录在哪里?
MTIA
约翰