Twitter Followers in iPhone sdk - iphone

How to make twitter followers list in iPhone sdk I m using MGTwitterEngine and when I try the following method:
[_engine getFollowersIncludingCurrentStatus:NO];
I m not getting followers list

USE like [_engine getFollowersIncludingCurrentStatus:YES];
And Call SOAuthEngine method to get list on console
- (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)connectionIdentifier {
NSLog(#"User Info Received: %#", userInfo);
followers = [[NSMutableArray alloc]init];
for (NSDictionary *u in userInfo ) {
Tweet *tweet = [[Tweet alloc]initWithTweetDictionary:u];
[followers addObject:tweet];
[tweet release];
}
[self.tableView reloadData];
}
Tweet is model class which has Dictionary and method like
- (NSString *)tweet {
return [tweets objectForKey:#"text"];
}

Related

In-app purchase, show products but nothing happens

I am trying to implement IAPs in one app but I'm still having difficulties with it. I followed various tutorials but all of them are out of date and full of errors. The only one that could work that I found is this one:
But I'm having a problem, the 3 products appear on my tableview but then when I click on one of them nothing happens... cell become blue and that's all... Am I missing something?
Or is that tutorial incomplete?
How do I run the purchase attempt?
Here is my code:
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
[productDetailsList addObjectsFromArray: response.products];
[productDisplayTableView reloadData];
}
-(void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
NSLog(#"Failed to connect with error: %#", [error localizedDescription]);
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [self.productDetailsList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *GenericTableIdentifier = #"GenericTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: GenericTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: GenericTableIdentifier];
}
NSUInteger row = [indexPath row];
SKProduct *thisProduct = [productDetailsList objectAtIndex:row];
[cell.textLabel setText:[NSString stringWithFormat:#"%# - %#", thisProduct.localizedTitle, thisProduct.price]];
return cell;
}
- (void)viewDidLoad
{
productDetailsList = [[NSMutableArray alloc] init];
productIdentifierList = [[NSMutableArray alloc] init];
for (short item_count=1; item_count <= 5; item_count++) {
[productIdentifierList addObject:[NSString stringWithFormat:#"com.mycompany.myapp.%d", item_count]];
}
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:productIdentifierList]];
request.delegate = self;
[request start];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
You need to have something in the lines of:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([SKPaymentQueue canMakePayments])
{
SKProduct *selectedProduct = [self.productDetailsList objectAtIndex:indexPath.row];
SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
}
Apple provides a decent step by step guide for handling in app purchases.
The main way to run IAPs involves a few different methods, but there are a few different steps you need to follow when implementing IAPs.
The first of these requirements are protocols. Please include each of the following protocols in your header file.
SKProductsRequestDelegate
SKPaymentTransactionObserver
SKRequestDelegate
You need the request methods:
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
if(response.products.count > 0)
{
SKProduct* product;
for(int i = 0; i<response.products.count; i++)
{
product = [response.products objectAtIndex:i];
if([product.productIdentifier isEqualToString:#"product identifier"])
{
self.currentProduct = product;
[self beginPaymentWithProduct:product];
}
}
}
}
I used the if statement to keep track of which product was being purchased. You will need an if-statement in that for-loop for each product identifier if you have multiple products. Use this later to unlock whatever on completion of the purchase.
You will also need the beginPayment method:
- (void)beginPaymentWithProduct:(SKProduct*)product
{
SKPayment *payment = [SKPayment paymentWithProduct:product];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
You also need the payment processing methods. I will not post all of them here as this would take far too much space, but I will give you the prototypes.
-(void)requestDidFinish:(SKRequest *)request;
-(void)request:(SKRequest *)request didFailWithError:(NSError *)error;
- (void)recordTransaction:(SKPaymentTransaction *)transaction;
- (void)finishTransaction:(SKPaymentTransaction *)transaction wasSuccessful:(BOOL)wasSuccessful;
- (void)completeTransaction:(SKPaymentTransaction *)transaction;
- (void)restoreTransaction:(SKPaymentTransaction *)transaction;
- (void)failedTransaction:(SKPaymentTransaction *)transaction;
For each of your buttons in your table that are supposed to be purchasing, they will need to perform a method similar to this one on the didSelectRowAtIndex... method:
- (void)buyCoins:(id)sender
{
if([self canMakePurchases])
{
ualRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:[NSArray arrayWithObjects: #"product identifier", nil]]];
[ualRequest setDelegate:self];
[ualRequest start];
}
}
This method will run the product request successfully. If you have all of these components in, you should have no problems.
I have used this code successfully in several apps.

Selecting and posting to a Facebook Friend's wall from an iOS app

I'm using the Facebook Hackbook sample code below in an app. The method getFriendsCallAPIDialogFeed says (in the comments) that this method "get's the user's friends, allowing them to pick one and post on their wall"
/*
* Helper method to first get the user's friends then
* pick one friend and post on their wall.
*/
- (void)getFriendsCallAPIDialogFeed {
// Call the friends API first, then set up for targeted Feed Dialog
currentAPICall = kAPIFriendsForDialogFeed;
[self apiGraphFriends];
}
however in line currentAPICall = kAPIFriendsForDialogFeed; it calls the request method below and then kAPIFriendsForDialogFeed.
The problem I'm having is that it picks a user's friend randomly. I need the user to be able to select a friend of their choice instead.
thanks for any help
- (void)request:(FBRequest *)request didLoad:(id)result {
[self hideActivityIndicator];
if ([result isKindOfClass:[NSArray class]] && ([result count] > 0)) {
result = [result objectAtIndex:0];
}
switch (currentAPICall) {
case kAPIFriendsForDialogFeed:
{
NSArray *resultData = [result objectForKey: #"data"];
// Check that the user has friends
if ([resultData count] > 0) {
// Pick a random friend to post the feed to
int randomNumber = arc4random() % [resultData count];
[self apiDialogFeedFriend:
[[resultData objectAtIndex: randomNumber] objectForKey: #"id"]];
} else {
[self showMessage:#"You do not have any friends to post to."];
}
break;
}
this code populates a table with all friends, from which you can select. the selection only posts a message/request to their notifications and not to their walls - which is what I need.
case kAPIGetAppUsersFriendsUsing:
{
NSMutableArray *friendsWithApp = [[NSMutableArray alloc] initWithCapacity:1];
// Many results
if ([result isKindOfClass:[NSArray class]]) {
[friendsWithApp addObjectsFromArray:result];
} else if ([result isKindOfClass:[NSDecimalNumber class]]) {
[friendsWithApp addObject: [result stringValue]];
}
if ([friendsWithApp count] > 0) {
[self apiDialogRequestsSendToUsers:friendsWithApp];
} else {
[self showMessage:#"None of your friends are using Whatto."];
}
[friendsWithApp release];
break;
}
Use the resultData to populate a table and then move the posting code into the didSelectRowAtIndexPath.
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self apiDialogFeedFriend:
[[resultData objectAtIndex: indexPath.row] objectForKey: #"id"]];
}
This SO question tells you how to post to a friend's wall: Facebook API: Post on friend wall

Iphone iAp [response.products count] is empty

Thats the problem - i have no products in my response for the iAp products.
I've read many themes about it here, at stackoverflow, plus here:
http://troybrant.net/blog/2010/01/invalid-product-ids/
And its all "YES". But it still wont work.
My appid iAps is ON, my provisioning new, my iapps connected to the App, and Cleared for sale, so...
Please, help.
PS. All the identifiers, that i've sent, returns me in the response.invalidProductIdentifiers array
PPS. itunes connect account was linked in Australia. (But in the account all stores was included for selling)
- (void)sendProductRequest:(NSString *)ID {
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:ID]];
request.delegate = self;
[APPDELEGATE increaseNetworkUseCount];
[request start];
}
- (void)sendProductRequestForCourseTests {
[self sendProductRequest:#"au.bla.blabla.blablabla.inapptesting"]; // for example. 100% matching with my productID at itunes connect
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
for (int i = 0; i < [response.invalidProductIdentifiers count]; i ++) {
NSLog(#"%#", [response.invalidProductIdentifiers objectAtIndex:i]); // here we have my Product id
}
DbgLog(#"Products count in received responce: %d", [response.products count]); // here i've got Zero!
SKProduct* product = [response.products count] > 0 ? [response.products objectAtIndex:0] : nil;
if (product) {
//NSString *storeProductID = myProduct.productIdentifier;
//SKPayment *payment = [SKPayment paymentWithProductIdentifier:storeProductID];
SKPayment *payment = [SKPayment paymentWithProduct:product];
DbgLog(#"Payment request sent for product with id: %#", product.productIdentifier);
[[SKPaymentQueue defaultQueue] addPayment:payment];
} else {
[APPDELEGATE decreaseNetworkUseCount];
for (id <IAPManagerObserver> observer in observers) {
[observer IAPManager:self didFinishSuccessfully:NO withTransaction:nil];
}
}
[request autorelease];
}
check below points,
Does your project’s .plist Bundle ID match your App ID
Are you using the full product ID when when making an SKProductRequest
This is the normal scenario issue. Please check this items, it should resolve the issue.

Facebook-iOs-API How to get response in custom function

How to catch response in custom function? Basically answer gets:
- (void)request:(FBRequest *) request didReceiveResponse:(NSURLResponse *)response{
NSLog(#"I have some information");
// [wait stopAnimating];
//wait.hidden;
}
- (void)request:(FBRequest *) request didLoad:(id)result{
if ([result isKindOfClass:[NSArray class]]){
result = [result objectAtIndex:0];
}
else{
// dictionaryWithNames = result;
infoStatus.text = [result objectForKey:#"name"];
infiId.text = [result objectForKey:#"id"];
}
if ([result objectForKey:#"data"]){
arrayWithFriends = [result objectForKey:#"data"];
if (arrayWithFriends != nil) {
for (NSDictionary *output in arrayWithFriends){
NSString *namaFriends = [output objectForKey:#"name"];
NSLog(#"Your Friend %#", namaFriends);
infoStatus.text = #"If you could see konsole... You can't";
continue;
}
} else {
infoStatus.text = #"You Haven't Got friends or Mutuals";
}
}
}
But i need to have another function because its impossible(or too hard) to get all responses that i need, using only few patterns in this function.
you can use same schema as facebook developers in their sample application here
https://github.com/facebook/wishlist-mobile-sample/blob/master/iOS/Wishlist/Wishlist/HomeViewController.m
they create currentAPIcall variable and fill it depending on request like that:
/**
* Make a Graph API Call to get information about the current logged in user.
*/
- (void) apiFQLIMe {
currentAPICall = kAPIFQLMe;
// Using the "pic" picture since this currently has a maximum width of 100 pixels
// and since the minimum profile picture size is 180 pixels wide we should be able
// to get a 100 pixel wide version of the profile picture
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"SELECT uid, name, pic FROM user WHERE uid=me()", #"query",
nil];
[facebook requestWithMethodName:#"fql.query"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
}
- (void)request:(FBRequest *)request didLoad:(id)result {
[self hideActivityIndicator];
if ([result isKindOfClass:[NSArray class]]) {
result = [result objectAtIndex:0];
}
switch (currentAPICall) {
case kAPIFQLMe:
{
// This callback can be a result of getting the user's basic
// information or getting the user's permissions.
if ([result objectForKey:#"name"]) {
// If basic information callback, set the UI objects to
// display this.
self.profileNameLabel.text = [result objectForKey:#"name"];
// Get the pr
...

iphone xmppframework How do I list all the online users of my particular domain

I am using xmppframework for iPhone. I want to know how can I check all the available users of my particular domain?
Thanks
- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence {
NSString *presenceType = [presence type]; // online/offline
NSString *myUsername = [[sender myJID] user];
NSString *presenceFromUser = [[presence from] user];
if (![presenceFromUser isEqualToString:myUsername]) {
if ([presenceType isEqualToString:#"available"]) {
[_chatDelegate newBuddyOnline:[NSString stringWithFormat:#"%##%#", presenceFromUser, #"gmail.com"]];
} else if ([presenceType isEqualToString:#"unavailable"]) {
[_chatDelegate buddyWentOffline:[NSString stringWithFormat:#"%##%#", presenceFromUser, #"gmail.com"]];
}
}
}
USE this method to AppDelegate file.
In this create #protocol with newBuddyOnline method.
And where you want to show the list, you just use these method in that,..
- (void)newBuddyOnline:(NSString *)buddyName {
[onlineBuddies addObject:buddyName];
[self.TableView reloadData];
}
- (void)buddyWentOffline:(NSString *)buddyName {
[onlineBuddies removeObject:buddyName];
[self.TableView reloadData];
}