We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I haven't tested it for Evo, but it should work fine as long as you change the tag syntax. I don't think it contains any Revo-specific code.


    ------------------------------------------------------------------------------------------
    PLEASE, PLEASE specify the version of MODX you are using.
    MODX info for everyone: http://bobsguides.com/modx.html
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 38189
      • 31 Posts
      tried it in evo but it acts like it never reads the &screenName property when you call the snippet.
      (with the var dump comment taken off)
      object(stdClass)[4]
      public 'request' => string '/1/statuses/user_timeline.json?include_rts=1' (length=44)
      public 'error' => string 'Not authorized' (length=14)
      Time: Tweet: Time: Tweet:

      edit:

      Got it to work by removing:
      $sp =& $scriptProperties;


      and replacing:
      $screenName = isset($sp['screenName'])? '&screen_name=' . $sp['screenName'] : '';
      $id = isset($sp['userId'])? '&id=' . $sp['userId'] : '';
      $count = isset($sp['count'])? '&count=' . $sp['count'] : '';
      $includeRts = isset($sp['includeRts'])? $sp['includeRts'] : '1';


      with:
      $screenName = isset($screenName)? '&screen_name=' . $screenName : '';
      $id = isset($userId)? '&id=' . $userId : '';
      $count = isset($count)? '&count=' . $count : '';
      $includeRts = isset($includeRts)? $includeRts : '1';


      With that said, Bob I bought your book. Great freaking book laugh Gonna look into how to implement a tpl into this snippet. Loving modx so far. [ed. note: tonitox2 last edited this post 14 years, 1 month ago.]
        • 3749
        • 24,544 Posts
        Thanks for buying the book and for replying back with the code. wink

        I'm sure others will find the code useful.


        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 33997
          • 150 Posts
          Wonderful that you got it to work. I'm not so good at coding, so I ended up paying someone to get it working for me, I don't really know if they ended up using this or not; I think they used the skeleton of another snippet and customized it for me. Good call that you got it to work though!
            "Great spirits have always encountered violent opposition from mediocre minds." -Albert Einstein
            • 40395
            • 67 Posts
            <?php
            /* ShowTweets snippet */
            $screenName = isset($screenName)? '&screen_name=' . $screenName : '';
            $id = isset($userId)? '&id=' . $userId : '';
            $count = isset($count)? '&count=' . $count : '';
            $includeRts = isset($includeRts)? $includeRts : '1';
            
            
            $url = '<a href="http://api.twitter.com/1/statuses/user_timeline.json?include_rts='" target="_blank" rel="nofollow">http://api.twitter.com/1/statuses/user_timeline.json?include_rts='</a>
             . $includeRts . $id .  $screenName . $count;
            
            
            $tw = curl_init(); 
            curl_setopt($tw, CURLOPT_URL, $url);
            curl_setopt($tw, CURLOPT_RETURNTRANSFER, TRUE);
            $twi = curl_exec($tw);
            $twi = json_decode($twi);
            //echo var_dump($twi);
            $output = '';
            foreach ($twi as $tweet) {
             
               $output .=  'Time: ' . $tweet->created_at . "";
               $output .=  'Tweet: ' . $tweet->text . "";
            }
             
            curl_close($tw);
             
            return $output;
            ?>


            I'm trying to get this to work on my Evo site but I'm getting a parse error at line 9

            Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/mcpytemp/public_html/manager/includes/document.parser.class.inc.php(814) : eval()'d code on line 9


            Line 9 being the url$ api call - it seems to be the same as Bob's original but I can't get it to work. I suspect that it's an issue with the inverted comma's \ quotes ?

            just in case, my call is
            [!ShowTweets? &screenName=`BobRay` &count=`2`]
            [ed. note: alchemy last edited this post 13 years, 11 months ago.]
              • 3749
              • 24,544 Posts
              A agree, but I can't check it for you because the forum software has mangled that code.

              Try pasting the '$url =' code with http misspelled.


              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 40395
                • 67 Posts
                Quote from: BobRay at Oct 02, 2012, 06:53 PM
                A agree, but I can't check it for you because the forum software has mangled that code.

                I wonder if that's why my copy and paste didn't work.

                This is a better representation of what I have currently:

                $url = '<a href="hppp://api.twitter.com/1/statuses/user_timeline.json?include_rts='" target="_blank" rel="nofollow">hppp://api.twitter.com/1/statuses/user_timeline.json?include_rts='</a>
                 . $includeRts . $id .  $screenName . $count;





                  • 3749
                  • 24,544 Posts
                  Yes, there are definitely some messed up quotes in that (you need a better code editor wink ). I'm not sure what the output you're trying to get would look like. Can you post it?

                  The best method is to hard-code what you want and get it working. Then create the version with the variables.


                  ------------------------------------------------------------------------------------------
                  PLEASE, PLEASE specify the version of MODX you are using.
                  MODX info for everyone: http://bobsguides.com/modx.html
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 40395
                    • 67 Posts
                    LOL - it's the simple questions like that which make me realise that I'm properly out of my depth ! smiley

                    My assumption was that by placing [!ShowTweets? &screenName=`BobRay` &count=`2`] in the HTML to execute the php Snippet, the last two tweets would be output the screen.

                    On reflection I now realise that I need to make an effort to actually display $output which presumably will contain the time and content of the tweet, but with the parsing error hadn't got that far.

                    Ideally I'd like to be able to format the time differently to the content to look pretty.

                    I'm using editplus as my code editor, but I guess it's pretty old now.


                    Thanks for your help.




                      • 40395
                      • 67 Posts
                      $url = '<a href="http://api.twitter.com/1/statuses/user_timeline.json?include_rts=" target="_blank" rel="nofollow">http://api.twitter.com/1/statuses/user_timeline.json?include_rts=</a>' . $includeRts . $id .  $screenName . $count; 


                      With some help, the above seems to process OK. The resulting $url when pasted into a browser returns a plausible result from the twitter API.

                      "hppp://api.twitter.com/1/statuses/user_timeline.json?include_rts=1&screen_name=BobRay&count=2" 


                      Trouble is modx then returns a parse error "Invalid argument supplied for foreach()" which is the element at line 22 above.

                      I looks like something has changed since your original post (which wasn't for EVO anyway). I was hoping it would paste in relativly easily so don't worry about debugging it - I'll try and sort it out in a different way smiley [ed. note: alchemy last edited this post 13 years, 11 months ago.]