a development blog for SharePoint,
Office 365, Azure, and whatever else falls across my path

Manually Like Links in SharePoint 2010

| No TrackBacks
Have you ever wanted SharePoint's social functionality to work a bit more like Facebook's? OOB, SharePoint allows you to like a page, but you have to be on that page to do it. Here is a JavaScript (+ jQuery) function to 'like' any URL that you want.

function likeUrl(pageUrl, pageTitle, context, successCallback, failCallback) {
    $.ajax({
        url: L_Menu_BaseUrl + "/_vti_bin/socialdatainternalservice.json/GetNormalizedPageUrl",
        dataType: 'json',
        type: 'POST',
        data: '{"pageUrl":"' + pageUrl + '"}',
        contentType: 'application/json; charset=utf-8',
        headers: { 'X-RequestDigest': document.getElementById('__REQUESTDIGEST').value },
        success: function (data) {
            $.ajax({
                url: L_Menu_BaseUrl + "/_vti_bin/socialdatainternalservice.json/AddQuickTag",
                dataType: 'json',
                type: 'POST',
                data: "{\"targetPage\":\"" + data.d + "\",\"title\":\"" + pageTitle.replace("\"", "\\\"") + "\",\"quickTagId\":0}",
                contentType: 'application/json; charset=utf-8',
                headers: { 'X-RequestDigest': document.getElementById('__REQUESTDIGEST').value },
                success: function () {
                    successCallback(context);
                },
                error: function () {
                    failCallback(context);
                }
            });
        },
        error: function () {
            failCallback(context);
        }
    });
}
Enhanced by Zemanta

No TrackBacks

TrackBack URL: http://codenutt.net/cgi-bin/mt/mt-tb.cgi/10

About Me

About this Entry

This page contains a single entry by Cody Nutt published on October 4, 2012 9:33 PM.

Report Viewer 2010 Rendering Issues in IE7 was the previous entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Categories