1

I want to short the URL from Social Share Buttons which are written in Javascript. The Script http://plugins.in1.com/share/demo

A Part Code of Social Share Script

var methods = {
    init : function(options) {
        this.share.settings = $.extend({}, this.share.defaults, options);
        var settings = this.share.settings,
        networks = this.share.settings.networks,
        theme = this.share.settings.theme,
        orientation = this.share.settings.orientation,
        affix = this.share.settings.affix,
        margin = this.share.settings.margin,
        pageTitle = this.share.settings.title||$(document).attr('title'),
        pageUrl = this.share.settings.urlToShare||$(location).attr('href'),
        pageDesc = "";

        $.each($(document).find('meta[name="description"]'),function(idx,item){
            pageDesc = $(item).attr("content");
        });

        // each instance of this plugin
        return this.each(function() {
            var $element = $(this),
            id=$element.attr("id"),
            u=encodeURIComponent(pageUrl),
            t=encodeURIComponent(pageTitle),
            d=pageDesc.substring(0,250),
            href;

            // append HTML for each network button
            for (var item in networks) {
                item = networks[item];
                href = helpers.networkDefs[item].url;
                href = href.replace('|u|',u).replace('|t|',t).replace('|d|',d)
                           .replace('|140|',t.substring(0,130));
                $("<a href='"+href+"' title='Share this page on "+item+
                    "' class='pop share-"+theme+" share-"+theme+"-"+item+"'></a>")
                            .appendTo($element);
            }

            // bind click
            $('.pop').click(function(){
                window.open($(this).attr('href'),'t','toolbar=0,resizable=1,status=0,width=640,height=528');
                return false;
            });


        });// end plugin instance

    }

My Script is doing in PHP which shorts visited Pages URL. The PHP Code for shortning URL

$short = file_get_contents('http://doma.in/api.php?api=sUio8Sy&url=' . urlencode('http://' . $_SERVER['HTTP_HOST']  . $_SERVER['REQUEST_URI']));

Calling the PHP Code

$url=json_decode($short,TRUE);
echo $url['short'];

This is to do here but I am not sure how

u=encodeURIComponent(pageUrl),
3
  • What is your problem? Commented Jun 15, 2013 at 13:21
  • Also you have used this keyword improperly. It will cause problem later. Commented Jun 15, 2013 at 13:22
  • The Script is not mine. Well I dont know much about Javascript. Thats why having the trouble. Want to short the Page URL and let the shorted URL share on Social Sites. Commented Jun 15, 2013 at 13:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.