This is a migrated thread and some comments may be shown as answers.

RadNotification(TwitterApp)

1 Answer 47 Views
Notification
This is a migrated thread and some comments may be shown as answers.
Luffy
Top achievements
Rank 1
Luffy asked on 04 Aug 2011, 02:37 PM
Hi, I am urgently looking for solution for implementing the Application Scenario(twitter). I wouldnt wan't to hard code to search for the keywords for the tweets.


But i want to pass in from a textbox/Session. Need help urgently.

Regards
  <script type="text/javascript">
var $ = $telerik.$;
 
 
      function GetTweetes(keywords, numPosts, fnk) {
 
          var url = "http://search.twitter.com/search.json?q=" + keywords + "&rpp=" + numPosts + "&callback=?";
 
          $.getJSON(url, function(data) {
              if ($.isFunction(fnk)) {
                  fnk.call(this, data.results);
              }
          });
      }
 
 
      function OnClientShowing(sender, args) {
 
          GetTweetes("Ajax", 10, function(data) {
              var rotator = $find("<%= tweetsRotator.ClientID %>");
              var currentItems = rotator.get_items();
 
              //scroll the rotator to the first item
              rotator.set_currentItemIndex(0);
 
              $(data).each(function(i, post) {
                  //if there is such an item created already - simply replace the content with the latest one
                  var dataItem = data[i];
 
 
                  var htmlString = "<div class='wrapper'>" + "<img class='profilePic' src='" + dataItem.profile_image_url + "'></img>" + "<div class='text'>" + dataItem.text + "</div><div class='date'><span class='author'>" + dataItem.from_user + " | </span>" + dataItem.created_at + "</div></div>";
 
                  if (currentItems[i]) {
                      currentItems[i].get_element().innerHTML = htmlString;
                  }
                  else {
                      //create and add a new item in case there is no such in the rotator - e.g in this demo this will be needed only on first show but in more complex scenario, when the returned by twitter records have different length
                      var radRotatorItemData = {};
                      radRotatorItemData.Html = htmlString;
                      rotator.addRotatorItem(radRotatorItemData, i);
                  }
              });
          });
      }
 
      function ShowNotification() {
          var notification = $find("<%= RadNotification1.ClientID %>");
          notification.show();
      }
 
                  </script>

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 05 Aug 2011, 12:15 PM
Hello Luffy,

 Please, note that your question is not directly related to RadControls but to Twitter API. For more dtails on how to use it in order to achieve your custom goals you could use its reference below:

https://dev.twitter.com/

or search the net:

http://www.google.bg/#hl=bg&source=hp&q=twitter+asp.net+&rlz=1R2ADFA_enBG375&oq=twitter+asp.net+&aq=f&aqi=&aql=&gs_sm=e&gs_upl=1221l5427l0l6738l18l16l1l8l8l0l212l1069l0.5.2l7l0&bav=on.2,or.r_gc.r_pw.&fp=f2548ca4818dd5d9&biw=1680&bih=955

For your particular question, the keyword which is passed for the search comes from the line below:

GetTweetes("Ajax", 10, function(data) { ....


and it is appended as such in the GetTweets method below:

function GetTweetes(keywords, numPosts, fnk) {
 
          var url = "http://search.twitter.com/search.json?q=" + keywords + "&rpp=" + numPosts + "&callback=?";

This being said, if e.g your input is called mySearchText you should pass its value in a manner similar to the following:

var txtVal = $get("mySearchText").innerHTML;
GetTweetes(txtVal, 10, function(data) {

I hope that my reply is detailed enough and helpful.

Regards,
Svetlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Notification
Asked by
Luffy
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question
or