在 XAMPP for ios 中获取注册用户

Posted

技术标签:

【中文标题】在 XAMPP for ios 中获取注册用户【英文标题】:Fetch registered user in XAMPP for ios 【发布时间】:2014-01-01 04:54:07 【问题描述】:

我正在开发一个 ios 项目中的 XAMPP。 我想在哪里获取所有注册用户..

下面是我使用的代码:-

NSError *error = [[NSError alloc] init];

NSXMLElement *query = [[NSXMLElement alloc] initWithXMLString:@"http://jabber.org/protocol/disco#items' node='all users'/>" error:&error];

XMPPIQ *iq = [XMPPIQ iqWithType:@"get" to:[XMPPJID jidWithString:@"DOMAIN"]

[appDel_friends.xmppStream sendElement:iq];

我得到一个错误错误代码 404 item not found。

请求:

SEND: <iq type="get" to="ios.ioschat.com" id="44BF120A-83F5-4AB8-85AD-006D752B716E"><query xmlns="http://jabber.org/protocol/disco#items" node="all users"/></iq>

回复:-

 RECV: <iq xmlns="jabber:client" type="error" id="44BF120A-83F5-4AB8-85AD-006D752B716E" from="ios.ioschat.com" to="user928@ios.ioschat.com/1661f8e6"><query xmlns="http://jabber.org/protocol/disco#items" node="all users"/><error code="404" type="cancel"><item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

请帮帮我..

【问题讨论】:

【参考方案1】:

试试这个

在视图中确实加载设置了这个

 [defaults setObject:@"your mid" forKey:@"kXMPPmyJID"];
   [defaults setObject:@"your password" forKey:@"kXMPPmyPassword"];
    [defaults synchronize];

- (NSFetchedResultsController *)fetchedResultsController

    if (fetchedResultsController == nil)
    
        NSManagedObjectContext *moc = [[self appDelegate ] managedObjectContext_roster];

        NSEntityDescription *entity = [NSEntityDescription entityForName:@"XMPPUserCoreDataStorageObject"
                                                  inManagedObjectContext:moc];

        NSSortDescriptor *sd1 = [[NSSortDescriptor alloc] initWithKey:@"sectionNum" ascending:YES];
        NSSortDescriptor *sd2 = [[NSSortDescriptor alloc] initWithKey:@"displayName" ascending:YES];

        NSArray *sortDescriptors = [NSArray arrayWithObjects:sd1, sd2, nil];

        NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
        [fetchRequest setEntity:entity];
        [fetchRequest setSortDescriptors:sortDescriptors];
        [fetchRequest setFetchBatchSize:10];

        fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
                                                                       managedObjectContext:moc
                                                                         sectionNameKeyPath:@"sectionNum"
                                                                                  cacheName:nil];
        [fetchedResultsController setDelegate:self];


        NSError *error = nil;
        if (![fetchedResultsController performFetch:&error])
        
            DDLogError(@"Error performing fetch: %@", error);
        

    

    return fetchedResultsController;


- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller

    [self.tableview reloadData];


- (void)configurePhotoForCell:(UITableViewCell *)cell user:(XMPPUserCoreDataStorageObject *)user

    // Our xmppRosterStorage will cache photos as they arrive from the xmppvCardAvatarModule.
    // We only need to ask the avatar module for a photo, if the roster doesn't have it.

    if (user.photo != nil)
    
        //cell.imageView.image = user.photo;
        UIImageView *imgview =[[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 45, 45)];
        imgview.image =user.photo;
        [cell addSubview:imgview];
    
    else
    
        NSData *photoData = [[[self appDelegate ] xmppvCardAvatarModule] photoDataForJID:user.jid];

        UIImageView *imgview =[[UIImageView alloc] initWithFrame:CGRectMake(5, 5, 45, 45)];
        if (photoData != nil)
            imgview.image = [UIImage imageWithData:photoData];
        else
            imgview.image = [UIImage imageNamed:@"defaultPerson"];

        [cell addSubview:imgview];

    


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

    return [[[self fetchedResultsController] sections] count];

- (NSString *)tableView:(UITableView *)sender titleForHeaderInSection:(NSInteger)sectionIndex

    NSArray *sections = [[self fetchedResultsController] sections];

    if (sectionIndex < [sections count])
    
        id <NSFetchedResultsSectionInfo> sectionInfo = [sections objectAtIndex:sectionIndex];

        int section = [sectionInfo.name intValue];
        switch (section)
        
            case 0  : return @"Available";
            case 1  : return @"Away";
            default : return @"Offline";
        
    

    return @"";


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

   /* if(frnds.count>0)
    
        return frnds.count;
    
    else
    
        return 0;
    
    */
    NSArray *sections = [[self fetchedResultsController] sections];

    if (section < [sections count])
    
        id <NSFetchedResultsSectionInfo> sectionInfo = [sections objectAtIndex:section];
        return sectionInfo.numberOfObjects;
    

    return 0;



/*-(float)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

    return 1;
*/


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

    static NSString *simpleTableIdentifier = @"Cell";

    UITableViewCell *cell;
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
/*  //  [cell.accessoryType ] =[UIColor colorWithRed:203.0/255.0f green:22.0/255.0f blue:110.0/255.0f alpha:1.0];
    if(frnds.count>0)
    
        UILabel *namelbl = [[UILabel alloc] initWithFrame:CGRectMake(20,15,200,30)];
        namelbl.text = [[frnds objectAtIndex:indexPath.row] valueForKey:@"first_name"] ;
        namelbl.font = [UIFont systemFontOfSize:15];
        [namelbl setMinimumFontSize:8];
        namelbl.textColor = [UIColor colorWithRed:203.0/255.0f green:22.0/255.0f blue:110.0/255.0f alpha:1.0];
        namelbl.textAlignment = NSTextAlignmentLeft;
       // [namelbl setNumberOfLines:2];
        [cell addSubview:namelbl];
        [namelbl release];
    
    */

    XMPPUserCoreDataStorageObject *user = [[self fetchedResultsController] objectAtIndexPath:indexPath];
    UILabel *namelbl = [[UILabel alloc] initWithFrame:CGRectMake(60,15,200,30)];
    namelbl.text = user.displayName;
    namelbl.font = [UIFont systemFontOfSize:15];
    [namelbl setMinimumFontSize:8];
    namelbl.textColor = [UIColor colorWithRed:203.0/255.0f green:22.0/255.0f blue:110.0/255.0f alpha:1.0];
    namelbl.textAlignment = NSTextAlignmentLeft;
    // [namelbl setNumberOfLines:2];
    [cell addSubview:namelbl];
    [namelbl release];

    [self configurePhotoForCell:cell user:user];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];

    return cell;

- (XMPPStream *)xmppStream 
    return [[self appDelegate ] xmppStream];


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath


    XMPPUserCoreDataStorageObject *user = [[self fetchedResultsController] objectAtIndexPath:indexPath];
    NSLog(@"user man %@",user.jidStr);




-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath


    return 50;


【讨论】:

以上是关于在 XAMPP for ios 中获取注册用户的主要内容,如果未能解决你的问题,请参考以下文章

在 ASP.Net MVC 应用程序中从 Facebook SDK for .Net 获取 Facebook 用户访问令牌

ntfs for mac 15注册码获取序列号如何正确获取

如何在 xampp 中获取 phpmyadmin 的登录选项

使用 cocoalibspotify for iOS 获取艺术家列表

更改密码后重新启动到默认 XAMPP 或获取用户 'root'@'localhost 的访问权限

如何在iOS中使用AWSMobileClient获取AWS Cognito用户属性?