How to get Mentions of other user using Linq To Twitter - linq-to-twitter

I want to get mentions of a any user using linq to twitter api. I have a code which brings back the user time line, but I want to get only mentions of a user, one of the method that is Mention Timeline can only be used to get mentions for authenticatd user but I want to get for any user. How it is possible? Here is my code which return a user timeline, what modification require in it? Please help
var mentions= await _twitterContext.Status
.Where(s => s.ScreenName== ScreenName && s.Type == StatusType.User && s.Count == 200)
.ToListAsync();

The Twitter API doesn't expose an endpoint that allows you to get mentions for any user with a screen name. However, you can get the mentions if you are authorized by the user for whom you want to get mentions for. Here's an example:
var tweets =
await
(from tweet in twitterCtx.Status
where tweet.Type == StatusType.Mentions &&
tweet.ScreenName == "JoeMayo"
select tweet)
.ToListAsync();
PrintTweetsResults(tweets);
The documentation for this is here:
http://linqtotwitter.codeplex.com/wikipage?title=Querying%20the%20Mentions%20Timeline&referringTitle=Making%20Status%20Queries%20and%20Calls

Related

Retrieving user metadata about a provisioned SoftLayer server comes back null

I'm trying to retrieve the user meta information for each machine consistently but what I'm finding is most of my machines are missing this data. I'd like to understand better what is required for this user data to be there. I'm curious if a server can be requested and provisioned without requiring user information (e.g. an API call to order a server and no user data is given). Or whether I am missing something in how I retrieve this information. Here is the basic ruby program I'm running:
user = ###
api_key = ###
client = SoftLayer::Client.new(:username => user, :api_key => api_key, :timeout => 999999)
list_of_virtual_machines = client['Account'].result_limit(i*50,50).object_mask("mask[id, billingItem[recurringFee, associatedChildren[recurringFee], orderItem[description, order[userRecord[username], id]]], userData]").getVirtualGuests
for x in 0..list_of_virtual_machines.length - 1
pp list_of_virtual_machines[i]['userData']
if list_of_virtual_machines[i]['billingItem'] && list_of_virtual_machines[i]['billingItem']['orderItem'] && list_of_virtual_machines[i]['billingItem']['orderItem']['order'] && list_of_virtual_machines[i]['billingItem']['orderItem']['order']['userRecord']
pp list_of_virtual_machines[i]['billingItem']['orderItem']['order']['userRecord']
end
end
My prints are consistently showing null. This question is related to a similar question I asked not too long ago (but the focus of that question moved towards the provisionDate):
How to get order username and provisionDate for all SoftLayer machines using Ruby?
They are missing that data because you did not added.
you can create the user data at moment to order a new server or VSI, you just have to send the data in your order request either using the createObject method or the placeOrder method. see http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObject
e.g.
{
"userData": [
{
"value": "someValue"
}
]
}
or you can set it after the server has been provisioned using these methods
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/setUserMetadata
http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/setUserMetadata
Basically the usermetadata are useful if you are going to use a post install script. The usermetadata value is not required to order a new server
take a look this article for examples:
http://sldn.softlayer.com/blog/jarteche/getting-started-user-data-and-post-provisioning-scripts

RavenDB Receiving not supported exception: Expression type not supported when using where query

I'm running the following query to try and find all relevant notifications to display to a user. However, Raven is not happy about something somewhere in the query. I've determined that the last 2 lines involving the date are fine, but the rest isn't (any of them seem to upset it). The only useful bit of information I'm getting is that it is "Expression type not supported: System.Linq.Expressions.TypedParameterExpression". None of these look unusually typed for LINQ.
One thing to mention is that action is an instance of an enum, with n.Actions being a list of them. Similarly with user.HiddenNotificationTypes and n.Type. I'm not sure if that could be what is throwing it.
/* Find all notifications that:
* Have no actions associated or the action that the user has performed
* There are no targets or the user is one of the targets
* The user is not one of the users that has seen this notification
* The notification type isn't one that the user has opted out of
* The current DateTime is after the notification's start time
* The current DateTime is before the expiry date of the notification
* */
notifications = session.Query<Notification>()
.Where(n => (n.Actions == null || action.In(n.Actions))
&& (n.Targets.Count == 0 || user.Id.In(n.Targets))
&& (!user.Id.In(n.UsersSeen))
&& (!user.HiddenNotificationTypes.Contains(n.Type))
&& (n.StartDate == DateTime.MinValue || n.StartDate > DateTime.Now)
&& (n.ExpireDate == DateTime.MinValue || n.ExpireDate < DateTime.Now))
.ToList();
Can anyone spot what might be causing this exception? Alternatively, if you think an index would work better for this query, what kind of index would I need?
Any help appreciated.
This one: user.HiddenNotificationTypes.Contains(n.Type)
You should also avoid using DateTime.Now in queries, it prevents queries from being cached.

How can I get more than 20 status's from the LinqToTwitter status?

I'm using this code to read status items from Twitter via LinqToTwitter.
IQueryable<Status> tweets =
twitterCtx.Status.Where(z => z.ScreenName == "HTM_Reisinfo" && z.Type == StatusType.User).Take(100);
But whatever number I pass to Take(), I only get 20.
Can I get more than 20?
The Twitter API does status paging through cursors, which LINQ to Twitter does support. Here's a related post with more explanation:
Return all tweets from my timeline

CRM 2011 LINQ invalid 'where' condition when using logicalname

Obvious attempt here is to get phone calls by a specific account ID, and ONLY phonecalls which have a regardingobject type of "account" (this is only a basic part of the full call, but even this fails).
var linqPhonecalls = from pc in svcContext.PhoneCallSet
where ((pc.RegardingObjectId.Id == account.Id) && (pc.RegardingObjectId.LogicalName == "account"))
select new
{
subj = pc.Subject,
stateCD = pc.StateCode,
};
Through research on the net I ran into this idea ( http://informeddynamicscrm.blogspot.com/2012/01/linq-restrictions-with-crm-2011-xrm.html ) and tried the following:
pc.RegardingObjectId.LogicalName.Equals("account") == true
As well as using Contains() and any other comparison operations I could try. It seems like the major problem here is the use of .LogicalName (also tried .Name)
Because I can't get it to work, I'm going to leave that check out of the equation for now, but I'd really like to put it in there because I'm going to be joining against other regarding types and want to sort things out.

Can Reminder be updated for windows phone

Would appreciate you help for the following.
I have created a reminder but I want to update it before or after the reminder nofiticaton has activated. here the code.
Problem : it wont work even if there is no compilation error for this code.
var Myreminders = ScheduledActionService.GetActions()
.Where(a => a.BeginTime.Month == month);
foreach (Reminder r in Myreminders)
{
string strMyRmd;
strMyRmd = r.Name.ToString();
if ( strMyRmd == "MyName1" )
{
r.Title = "Today Shopping";
}
}
Thanks
I believe (I can't test this from my computer but have confirmed this works with Background Agents) that you need to find your Reminder, remove it from the scheduled action service, update and re add it.
var reminder = (Reminder)ScheduledsActionService.Find("MyReminder");
ScheduledActionService.Remove("MyReminder");
reminder.Title = "Updated Title";
ScheduledActionService.Add(reminder);
According to the remarks section in ScheduledActionService.GetActions Method documentation page:
The Scheduled Action Service does not maintain a reference to the
objects returned by this method, and therefore the properties of the
objects are not updated to reflect the current state after the call to
GetActions. To obtain an object that is updated by the system as its
state changes, use Find(String) instead.
So, just use Find(String) instead.

Resources