Adding URL shortner to Tweet Old Post wordpress plugin

This is small tutorial showing you how to integrate new URL shortner to Tweet Old Post wordpress plugin

Make the following changes in top-admin.php file

1 – Look for the URL shortner drop down list, find the code that looks like below



2 – Once you get there, add another option tag to the list like below,

 

Note – In the above option replace ‘urlshortner’ with new shortner name.

Make the below changes in top-core.php file,

1 – find the function shorten_url(), and add an elseif block of new shortner api like below code,

elseif ($shortener=="urlshortner") {
		$url = "http://u.nu/unu-api-simple?url={$the_url}";
		$response = send_request($url, 'GET');
	}

Note – replace urlshortner with new shortner name, it should be same as in point 2 of top-admin.php changes. In the URL section change the API URL with your shortner API URL and pass the required parameters the above just have the URL parameter.

2 -Some API may require additional parameters like API key. So it will look somewhat like this,

elseif ($shortener=="urlshortner") {
		$url = "http://yourshortnerapiurl/api?url={$the_url}&api=xxxxxx";
		$response = send_request($url, 'GET');
	}

Note – replace urlshortner with new shortner name, it should be same as in point 2 of top-admin.php changes. In the URL section change the API URL with your shortner API URL and pass the required parameters. The above have the URL parameter and API key replace xxxxxx with your API Key value.

That’s it and you are ready to go. In case you find it difficult to implement the above code feel free to drop by a comment I’ll add it for everyone 🙂 and you can always drop me a mail.

MD5 Encryption in .Net and PHP

To get MD5 hash in C# use this method. It returns same value AS MD5() function in PHP

        public string GetMD5Hash(string input)
        {
            System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] bs = System.Text.Encoding.UTF8.GetBytes(input);
            bs = x.ComputeHash(bs);
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            foreach (byte b in bs)
            {
                s.Append(b.ToString("x2").ToLower());
            }
            string password = s.ToString();
            return password;
        }

And this one is in PHP


These both will return the same value