使用Tridion UGC web服务添加评级
我知道我可以通过教资会网络服务添加评论,方法如下:-使用Tridion UGC web服务添加评级,tridion,tridion-2011,tridion-content-delivery,ugc,Tridion,Tridion 2011,Tridion Content Delivery,Ugc,我知道我可以通过教资会网络服务添加评论,方法如下:- WebServiceClient ugcCall = new WebServiceClient(); string ugcData = "{ \"d\" :{\"Content\":\"" + comment + "\",\"Status\":2,\"ItemPublicationId\":\"" + PublicationId + "\",\"ItemId\":\"" + itemid + "\",\"ItemType\":\"16\",
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);
我的问题是,添加评级和好恶的语法是什么?这有文件记录吗
MTIA
John上传评级的命令是“/ratings”,而不是“/Comments”。当然,JSON也不同。在下面的代码中,我没有手动写出JSON,而是构建了一个简单的Rating对象,并使用JavascriptSerializer将其转换为JSON:
TcmUri tcmUri = new TcmUri(itemUri);
WSR_ContentDelivery.User user = new WSR_ContentDelivery.User { Id = GetUserId() };
WSR_ContentDelivery.Rating rating = new WSR_ContentDelivery.Rating
{
CreationDate = DateTime.UtcNow,
LastModifiedDate = DateTime.UtcNow,
ItemPublicationId = tcmUri.PublicationId,
ItemId = tcmUri.ItemId,
ItemType = tcmUri.ItemTypeId,
RatingValue = ratingValue.ToString(),
User = user,
Id = "0"
};
JavaScriptSerializer oSerializer = new JavaScriptSerializer();
WSClient.UploadString("/Ratings", "POST", "{d:" + oSerializer.Serialize(rating) + "}", GetUserId());
最好补充一点,WebServiceClient在UGC中不是公共API,将来可能会改变。感谢Quirijn的例子!谢谢你,丹尼尔。你有更多的信息吗?是否有计划将其公开?你知道在不久的将来可能会有什么变化吗?目前,还没有计划将其公开,但你可以放心,因为在接下来的两个版本中没有计划对该领域进行任何变化。谢谢Daniel。非常感谢。