اقای مدائنی عزیز
سایت goo.gl ادرس یه مطلب بهش مدیدم و لینک کوتاه اون مطلب بهمون میده
آیا میشه کاری کرد که با کدنویسی لینک مطلب روی goo.gl کوتاه کنه و بهمون بده؟
بله میشه
این لینک توضیح داده
اینم لینک اصلی Api
private const string key = "xxxxxx mykey xxxxxxx"; public static string Shorten(string url) { string post = "{\"longUrl\": \"" + url + "\"}"; string shortUrl = url; HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.googleapis.com/urlshortener/v1/url?key=" + key); try { request.ServicePoint.Expect100Continue = false; request.Method = "POST"; request.ContentLength = post.Length; request.ContentType = "application/json"; request.Headers.Add("Cache-Control", "no-cache"); using (Stream requestStream = request.GetRequestStream()) { byte[] postBuffer = Encoding.ASCII.GetBytes(post); requestStream.Write(postBuffer, 0, postBuffer.Length); } using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { using (Stream responseStream = response.GetResponseStream()) { using (StreamReader responseReader = new StreamReader(responseStream)) { string json = responseReader.ReadToEnd(); shortUrl = Regex.Match(json, @"""id"": ?""(?<id>.+)""").Groups["id"].Value; } } } } catch (Exception ex) { // if Google's URL Shortner is down... System.Diagnostics.Debug.WriteLine(ex.Message); System.Diagnostics.Debug.WriteLine(ex.StackTrace); } return shortUrl; }
من یه دکمه گداشتم داخل صفحه و در پشت دکمه نوشتم
Shorten(TextBox1.Text);
تکس باکشادرس صفحه رو میگره ولی لینک کوتاه نشون نمیده
اقای مدائنی راهنمایی نمیکنید
تجربه ای در این ضمینه ندارم دوست من
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)