Hello, we developep a Sharepoint hosted add'in the will Set Like and Unlike a particular List Item. We initially used the API Microsoft.Office.Server.ReputationModel.Reputation.setLike and it seems not working. Here is the program we used.We need to
run the program in Sharepoint Online
$.getScript(hostweburl + "/_layouts/15/" + "MicrosoftAjax.js", function () {
$.getScript(hostweburl + "/_layouts/15/" + "SP.core.js", function () {
$.getScript(hostweburl + "/_layouts/15/" + "init.debug.js", function () {
$.getScript(hostweburl + "/_layouts/15/" + "Reputation.js", function () {
blogURL = hostweburl + "/searchblog";
var like = false;
var likeButtonText = $("a.LikeButton").text();
likeButtonText = "Like";
if (likeButtonText != "") {
if (likeButtonText == "Like")
like = true;
var clientContext = new SP.ClientContext(appweburl);
var factory = new SP.ProxyWebRequestExecutorFactory(appweburl);
clientContext.set_webRequestExecutorFactory(factory);
var appContextSite = new SP.AppContextSite(clientContext, blogURL);
var context = new SP.ClientContext(blogURL);
EnsureScriptFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function () {
Microsoft.Office.Server.ReputationModel.
Reputation.setLike(appContextSite,
listid,
itemid, like);
clientContext.executeQueryAsync(
function () {
//alert(String(like));
//GetLikeCount();
}, function (sender, args) {
alert('Request failed. ' + args.get_message()+ '\n' + args.get_stackTrace());
});
});
}
});
});
});
});