Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.Serialization;
- using System.ServiceModel;
- using System.ServiceModel.Web;
- using System.Text;
- using LinqToTwitter;
- using System.Configuration;
- namespace Twitter.WCF
- {
- public class Tweets
- {
- public List<Search> GetTweets()
- {
- var auth = new SingleUserAuthorizer
- {
- Credentials = new SingleUserInMemoryCredentials
- {
- ConsumerKey =
- ConfigurationManager.AppSettings["twitterConsumerKey"],
- ConsumerSecret =
- ConfigurationManager.AppSettings["twitterConsumerSecret"],
- TwitterAccessToken =
- ConfigurationManager.AppSettings["twitterAccessToken"],
- TwitterAccessTokenSecret =
- ConfigurationManager.AppSettings["twitterAccessTokenSecret"]
- }
- };
- var twitterCtx = new TwitterContext(auth);
- var srch =
- (from search in twitterCtx.Search
- where search.Type == SearchType.Search &&
- search.Query == "Hospital" &&
- search.Count == 25
- select search)
- .ToList();
- return srch;
- }
- public IQueryable<Search> SearchResults
- {
- get
- {
- return GetTweets().AsQueryable();
- }
- }
- }
- }
- //------------------------------------------------------------------------------
- // <copyright file="WebDataService.svc.cs" company="Microsoft">
- // Copyright (c) Microsoft Corporation. All rights reserved.
- // </copyright>
- //------------------------------------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.Data.Services;
- using System.Data.Services.Common;
- using System.Linq;
- using System.ServiceModel.Web;
- using System.Web;
- namespace Twitter.WCF
- {
- public class Twitter : DataService<Tweets>
- {
- public static void InitializeService(DataServiceConfiguration config)
- {
- config.SetEntitySetAccessRule("SearchResults", EntitySetRights.AllRead);
- config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
- config.UseVerboseErrors = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement