1
我想轉換tweet url,例如https://twitter.com/LindseyGrahamSC/status/320202348263780352,以便它自動嵌入。到目前爲止,我認爲最好的方法是使用短的代碼類型語法,例如[tweet:320202348263780352],然後製作嵌入的tweet。但我真的想只是粘貼的網址,並讓它工作。我堅持如何實現這一目標。我到目前爲止:轉換tweet鏈接,以便將其嵌入到asp.net應用中
var ctxTwitterContext = new TwitterContext(auth);
if (e.Location != ServingLocation.PostList && e.Location != ServingLocation.SinglePost)
return;
string regex__1 = @"\[tweet:.*?\]";
MatchCollection matches = Regex.Matches(e.Body, regex__1);
for (int i = 0; i < matches.Count; i++)
{
Int32 length = "[tweet:".Length;
string TweetID = matches[i].Value.Substring(length, matches[i].Value.Length - length - 1);
var embeddedStatus =
(from tweet in ctxTwitterContext.Status
where tweet.Type == StatusType.Oembed &&
tweet.ID == TweetID
select tweet.EmbeddedStatus)
.SingleOrDefault();
string html = embeddedStatus.Html;
e.Body = e.Body.Replace(matches[i].Value, String.Format(html));