I want to get latest tweets posted after a particular tweet/time. I'm using MGTwitterEngine for iOS.
I fetch the id of the last tweet posted like this (variable statusId)
- (void)statusesReceived:(NSArray *)statuses forRequest:(NSString *)connectionIdentifier`
{
NSMutableDictionary *statusDict = [NSMutableDictionary dictionaryWithDictionary:[[Shared sharedInstance].tweets objectAtIndex:i]];
NSString *idstr = [statusDict valueForKey:#"id"];
statusId = unsigned long version of idstr using NSNumberFormatter;
}
I store this statusId as a global variable and again when I call
-(void) getTweets
{
[twitterEngine getUserTimelineFor:title sinceID:statusId startingAtPage:0 count:20];
}
it returns the old tweets and not new ones posted after the last tweet.
Also when I do an NSLog of the statusID stored and the string value of the ID, they are printed different (even though according to docs, both should be unsigned long)
Can someone please let me know how to get tweets posted after a specific tweet/time?
Thanks.
Is there no solution t this problem. I posted the problem yesterday and since then no reply has come.
In order to get the latest tweets statusID has to be a unsigned long long.
Related
I want to create UUID, I have code below which can create UUID, how can I create UDID with multiple vendors same ID in iOS7?
+ (NSString*) stringWithNewUUID
{
CFUUIDRef uuidObj = CFUUIDCreate(nil);
NSString *newUUID = (NSString*)CFUUIDCreateString(nil, uuidObj);
CFRelease(uuidObj);
return newUUID;
}
The CFUUIDCreate function produces a version 4 UUID which is taken entirely from a pseudo-random number generator. There are no timestamps or MAC addresses embedded in this type of UUID. (That refers to the little-used version 1 flavour.) These are safe to use for nearly all applications.
This method returns random UUID in iOS 6 and above
[[UIDevice currentDevice]identifierForVendor]
I have created a vendor ID and then saved it with keychain, which I am retaining for next time using KeychainWrapper keychainStringFromMatchingIdentifier:...
The UUID that the code produces above does not have a recoverable time stamp in it. It's just a string that looks something like this: E1D87006-7CD0-4E28-9768-624DA92F75D6
I followed Sandeep Khade's answer and made following code using PDKeychainBindings. It's same as using NSUserDefaults but it keeps identifier in keychain which saves data even when application is deleted.
+ (NSString *)uniqueVendor {
PDKeychainBindings *keychain = [PDKeychainBindings sharedKeychainBindings];
NSString *uniqueIdentifier = [keychain objectForKey:kKeyVendor];
if (!uniqueIdentifier || !uniqueIdentifier.length) {
NSUUID *udid = [[UIDevice currentDevice] identifierForVendor];
uniqueIdentifier = [udid UUIDString];
[keychain setObject:uniqueIdentifier forKey:kKeyVendor];
}
return uniqueIdentifier;
}
I recently try to change the Json library in my applicaiton from SBJson to the NSJSONSerialization.
When I do this job, I find there are some key value that I can not get out.
Here is an example of the NSDictionary I get after NSJSONSerialization:
{
id = 4028;
"novel_author" = "XYZ";
"novel_pub" = "ABC";
"novel_title" = "DATE LIVE";
updatedate = "2013-01-13 22:31:13";
"vol_click" = 7563;
}
The original Json data string is:
{
"id":"4028",
"vol_click":"7563",
"updatedate":"2013-01-13 22:31:13",
"novel_author":"XYZ",
"novel_pub":"ABC",
"novel_title":"DATE LIVE"
}
I can not get the value of the key "id" out.
[NSDictionary objectForKey#"id"] is useless.
Is there anyone have idea how to get the value out?
As you can tell by the output of what looks like NSLog("%#", dict);, the JSON deserialization process works fine.
The dictionary contains a key called "id", so [dict objectForKey:#"id"] should also work fine.
I can only conclude that this isn't the actual cause of the trouble you're having.
Either of these should work:
[yourDictName valueForKey:#"id"]
[yourDictName objectForKey:#"id"]
If you can see the value using NSLog to display the dictionary, then it is there. Beyond that, make sure your object is not getting nil'd or released or freed.
In my app i'm using a users feeds to retrieve al the post done by my app. I simply retrieve al the posts, and the compare on every post the id number of the app.
This work ok. But i've found a bug in this method. Since the application node isn't always consistent. Normally when there is a post which is not done by an app, the entry in the dictionary just says (null), there isn't any data. This doesn't give any problems.
But there is an app which has other data in the this application node. This one has data in this node which specifically says (note the difference between () and <> ). But I can't seem any way to check if the dictionary with that post has in it. i've tried the following:
NSDictionary *resultPost1 =[resultPost objectForKey:#"application"];
NSLog(#"result%#", [resultPost objectForKey:#"application"]);
if ([resultPost1 count] != 0) {
This one gives a sigabrt, with the following nslog before the sigabrt:
result(null)
result{
id = 1957711133323244365557378;
name = "app";
}
result< null > (added space for visibility)
I've also tried isEqualtoString:#"< null>" Also without success.
It looks like sometimes, their is an dictionary in the application node, and sometimes a string .
Anyone has clue??? Thanks!!!
You will have to do some checking as you don't have a guarantee as to what sort of object is returned from the dictionary.
NSDictionary *resultPost1 = [resultPost objectForKey:#"application"];
if ([[resultPost1 class] isKindOfClass:[NSDictionary class]) {
//Treat as a dictionary
}
else if ([[resultPost1 class] isKindOfClass:[NSString class]) {
//Treat as a string
}
else if ([resultPost1 isEqual:[NSNull null] || !resultPost) {
//Treat as Null, note the json library Facebook uses might set
//a json NULL into a NSNull object instead of nil
}
this is hard to describe but I am currently catching a string from a database, this string can be 1-4 characters long, however I am wanting to always display 4 characters, so if i get say a string back that is 34, i want it to be 0034.
I have set up a method to catch the string so now I just need to figure out how to do this. what I then plan to do is feed that string into a NSArray so I can send each [i'th] of the array off to 4 differetn methods that control animations in my app.
The reason its in string format is because I have had to bounce it round from hex, to int to string for various formatting reasons within the application.
this is my code i have so far. Suggestions/solutions would be great thankyou, I am so new its hard to find solutions for stuff like string manipulation etc..
//... other method I am getting the string from/.
[self formatMyNumber:dataString];
///..
-(void)formatMyNumber:(NSString *)numberString{
//resultLabel.text = numberString; //check to make sure string makes it to here.
//NSLog(#"hello From formatMyNumber method"); //check
}
//..
//the with send off each character to 4 animation methods that accept integers.
- (void)playAnimationToNumber:(int)number{
//...
//UpDated... weird stuff happening.
here is my method so far.
//Number Formatter
-(void)formatMyNumber:(NSString *)numberString{
NSLog(#"This is what is passed into the method%#",numberString);
int tempInt = (int)numberString;
NSLog(#"This is after I cast the string to an int %i",tempInt);
//[NSString alloc] stringWithFormat:#"%04d", numberString];
NSString *tempString = [[NSString alloc] initWithFormat:#"%04d", tempInt];
NSLog(#"This is after I try to put zeros infront %#",tempString);
//resultLabel.text = tempString;
//NSLog(#"hello From formatMyNumber method");
}
this is the output.
[Session started at 2011-06-19
16:18:45 +1200.] 2011-06-19
16:18:54.615 nissanCode0.1[4298:207]
731 2011-06-19 16:18:54.616
nissanCode0.1[4298:207] 79043536
2011-06-19 16:18:54.617
nissanCode0.1[4298:207] 79043536
2011-06-19 16:18:54.617
nissanCode0.1[4298:207] hello From
formatMyNumber method
As far as the number of zeros preceding your string goes there are a couple of ways to do this. I'd suggest:
NSString *myString = [NSString stringWithFormat:#"%04d",[dataString intValue]];
Is it possible you could have the number in integer form instead of string form? If so, it's pretty easy to use [NSString stringWithFormat:#"%04d", number]. See here for a list of the possible format specifiers.
See what stringWithFormat: can do. I realize you mentioned your numbers are NSStrings, but if they were ints, or you convert them back to ints, the following may do the trick. Modify the following to best suit your need:
return [NSString stringWithFormat:#"%04d", number];
Hello Facebook gurus :)
I'd like some help on this one
This is a post I made on a picture and then I liked it:
{
"created_time" = "2011-06-07T23:23:19+0000";
from = {
id = xxxxxxxxxxxxxx;
name = "Adrien xxxxxxxx";
};
id = "107817942643477_24293";
likes = 1;
message = baar;
"user_likes" = 1;
}
I'm trying to get the userID's of friends/me who liked this comment I made on a picture
I made this :
https://graph.facebook.com/107817942643477_24293/likes?access_token=TOKEN
I tried too with Fql:
NSString *theQuery = [NSString stringWithFormat:#"SELECT likes FROM stream WHERE post_id=\"%#\"", postID];
id theResult = [[AppDelegate sharedFacebook]
sendSynchronousRequestWithMethodName:#"fql.query"
andParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:
theQuery, #"query", nil]
andHttpMethod:#"GET"];
It doesn't work, maybe because this comment is liked to a picture and I should format the request differently ?
The only thing I'm receiving is an empty array
{
data = (
);
}
What am I doing wrong ?
Thanks in advance for any help on this one.
Ps: I'm using the iOS Facebook library, could it be broken ?
You need to include the user id. Taking the example from the Facebook documentation here:
http://developers.facebook.com/docs/reference/api/Comment/
Click on the link there and add '/likes' before the query string containing the access token:
https://graph.facebook.com/19292868552_475058873552_14173716/likes?access_token=2227470867|2.AQDprvRAYwU-6lHe.3600.1309028400.0-604597322|Z4r0uxTK5ctlAn5rbs2NUNYZr88
If you remove the user id from the id, however...
https://graph.facebook.com/475058873552_14173716/likes?access_token=2227470867|2.AQDprvRAYwU-6lHe.3600.1309028400.0-604597322|Z4r0uxTK5ctlAn5rbs2NUNYZr88
...it won't work.
So you need to manually add the user id to your comment id if it's not already present.