Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • syn-rg 282 posts 425 karma points
    Jul 04, 2013 @ 09:23
    syn-rg
    0

    What to do when the connection to Twitter fails

    I've noticed that occasionally the connection to Twitter is failing and this causes the macro to wrap around all my other elements, as it's now "empty".

    I've set my macro cache at 600 seconds. What do you recommend I do in the case that the connection fails?

    I don't want visitors seeing my page broken up when the "uTweet.ListOfTweets.cshtml" fails to connect and wraps around my elements.

    Look forward to hearing your suggestions.

    Cheers, JV

  • Nick Garrard & Davy Belmans 25 posts 142 karma points
    Jul 04, 2013 @ 10:10
    Nick Garrard & Davy Belmans
    100

    Hi,

    What do you mean with 'wrap around my other elements' ?

    Maybe you can change the script's code and add some extra check's to provide feedback when no tweets are shown.

    @{
    
        int nrOfTweets = String.IsNullOrEmpty(Parameter.nrOfTweets) ? 10 : int.Parse(Parameter.nrOfTweets);
    
        try
        {
            var t = new uTweets.Tweets();
            var result = t.GetTweets();
            if (result != null)
            {
                <ul>
                    @foreach(var tw in result.Take(nrOfTweets))
                    {
                        <li>@(tw.Author): @Html.Raw(tw.TextAsHtml) (@tw.CreatedDate) (@tw.RelativeTime)</li>
                    }
                </ul>
            }
            else
            {
                <p>No tweets found</p>
            }
        }
        catch (Exception ex)
        {
            <p>Sorry, twitter failed</p>;
        }
    }

    Kind regards

    Nick

  • syn-rg 282 posts 425 karma points
    Jul 05, 2013 @ 01:50
    syn-rg
    0

    Thanks Nick, that works nicely.

    Cheers, JV

Please Sign in or register to post replies

Write your reply to:

Draft