iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – Twitter引擎SA_OAuthTwitterEngine集成?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的应用程序中成功添加了SA_OAuthTwitterENGIne但是我遇到了一个非常奇怪的问题.当我登录Twitter时,我的应用程序将崩溃:

- (void) OAuthTwitterController: (SA_OAuthTwitterController *) controller authenticatedWithUsername: (NSString *) username 
{
    [_ENGIne sendupdate:[NSString StringWithFormat:@"This Tweet for tesTing!"]];
    NSLog(@"Authenicated for %@",userName);
}

该应用程序崩溃[_ENGIne sendupdate:[NSString StringWithFormat:@“此Tweet进行测试!”]] ;.如果我使用[_ENGIne sendupdate:nil];相反,它会工作而不会崩溃,但不能从我的帐户发送推文.

我试图跟踪sendupdate方法时,我在[therequest prepare]上遇到了实际问题;以下函数声明,

- (NSString *)_sendrequestWithMethod:(NSString *)method path:(NSString *)path queryParameters:(NSDictionary *)params body:(NSString *)body requestType:(MGTwitterrequestTypE)requestType responseType:(MGTwitterResponseTypE)responseType
{
    NSString *fullPath = path;
    NSString *urlString = [NSString StringWithFormat:@"%@://%@/%@",(_secureConnection) ? @"https" : @"http",_APIDomain,fullPath];
    NSURL *finalURL = [NSURL URLWithString:urlString];
    if (!finalURL) {
        return nil;
    }
OAMutableURLrequest *therequest = [[OAMutableURLrequest alloc] initWithURL:finalURL consumer:self.consumer  token:_accessToken realm: nil signatureProvider:nil];
    if (method) {
        [therequest sethttpR_483_11845@ethod:method];
    }
    [therequest sethttpShouldHandleCookies:NO];

    // Set headers for client information,for tracking purposes at Twitter.
    [therequest SETVALue:_clientName    forhttpHeaderField:@"X-Twitter-Client"];
    [therequest SETVALue:_clientVersion forhttpHeaderField:@"X-Twitter-Client-Version"];
    [therequest SETVALue:_clientURL     forhttpHeaderField:@"X-Twitter-Client-URL"];

    // Set the request body if this is a POST request.
    BOOL isPOST = (method && [method isEqualToString:@"POST"]);
    if (isPOST) {
        // Set request body,if specified (hopefully so),with 'source' parameter if appropriate.
        NSString *finalBody = @"";
        if (body) {
            finalBody = [finalBody StringByAppendingString:body];
        }
        if (_clientsourceToken) {
            finalBody = [finalBody StringByAppendingString:[NSString StringWithFormat:@"%@source=%@",(body) ? @"&" : @"?",_clientsourceToken]];
        }

        if (finalBody) {
            [therequest sethttpBody:[finalBody dataUsingEncoding:NSUTF8StringEncoding]];
        }
    }
    [therequest prepare];

    // Create a connection using this request,with the default timeout and caching policy,// and appropriate Twitter request and response types for parsing and error reporTing.
    MGTwitterhttpURLConnection *connection;
    connection = [[MGTwitterhttpURLConnection alloc] initWithrequest:therequest delegate:self requestType:requestType responseType:responseType];

    if (!connection) {
        return nil;
    } else {
        [_connections setObject:connection forKey:[connection identifier]];
    }

    return [connection identifier];
}

崩溃报告是,

0  0x01f023ef in CFRelease ()
1  0x0008d04c in -[OAMutableURLrequest URLEncodedString:] (self=0x7bc673b0,_cmd=0x9ee5f,String=0x0) at /Users/ben/DropBox/Dev/External Projects/Twitter-OAuth-iPhone/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAMutableURLrequest.m:287
2  0x0008bbe3 in -[OAMutableURLrequest prepare] (self=0x7bc673b0,_cmd=0x978cC) at /Users/ben/DropBox/Dev/External Projects/Twitter-OAuth-iPhone/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAMutableURLrequest.m:131
3  0x00088460 in -[SA_OAuthTwitterENGIne _sendrequestWithMethod:path:queryParameters:body:requestType:responseType:] (_cmd=0x96833,method=0xc0250,body=0x7b971210,requestType=<value temporarily unavailable,due to optimizations>) at SA_OAuthTwitterENGIne.m:315

4  0x0007f673 in -[MGTwitterENGIne sendupdate:inReplyTo:] (self=<value temporarily unavailable,due to optimizations>,_cmd=0x96914,updatEID=2073243024) At MGTwitterENGIne.m:1019

5  0x0007f496 in -[MGTwitterENGIne sendupdate:] (self=0x7b932d90,_cmd=0x95e02,status=0xc0510) at MGTwitterENGIne.m:995

6  0x0007bf3f in -[DMUAppDelegate OAuthTwitterController:authenticatedWithUsername:] (self=0x7b918a20,_cmd=0x96152) at DMUAppDelegate.m:572

7  0x0008503b in -[SA_OAuthTwitterController gotPin:] (_cmd=0x975b4,pin=0x7ae573e0) at SA_OAuthTwitterController.m:125

8  0x00086137 in -[SA_OAuthTwitterController webViewDidFinishLoad:] (self=0x7b944a00,_cmd=0xf070e2,webView=0x7ae46750) at SA_OAuthTwitterController.m:224

9  0x00be036a in -[UIWebView webView:didFinishLoadForFrame:] ()

10 0x00be1956 in -[UIWebViewWebViewDelegate webView:didFinishLoadForFrame:] ()

11 0x01f5c51d in __invoking___ ()

12 0x01f5c437 in -[NSInvocation invoke] ()

13 0x01f8749a in -[NSInvocation invokeWithTarget:] ()

14 0x03462aff in -[_WebSafeForWARDer forWARDInvocation:] ()
15 0x01f5d0c9 in ___forWARDing___ ()
16 0x01f5cce2 in __forWARDing_prep_0___ ()

17 0x01f5c51d in __invoking___ ()
18 0x01f5c437 in -[NSInvocation invoke] ()

19 0x04005ae3 in Sendmessage ()
20 0x04006115 in HandleDelegatesource ()

21 0x01fca97f in __CFRUNLOOP_IS_CALLING_OUT_TO_A_sourcE0_PERFORM_FUNCTION__ ()
22 0x01f2db73 in __CFRunLoopDosources0 ()
23 0x01f2d454 in __CFRunLoopRun ()
24 0x01f2cdb4 in CFRunLoopRunSpecific ()
25 0x01f2cccb in CFRunLoopRunInMode ()
26 0x01e60879 in GSEventRunModal ()
27 0x01e6093e in GSEventRun ()

28 0x00a29a9b in UIApplicationMain ()
29 0x00040296 in main (argc=1,argv=0xc003c604) At /Users/dhirenshah/Desktop/Projects/Projects/DMU/DMU/main.m:16
(gdb)

解决方法

是的,最后我解决了我的问题.我只是替换代码,

- (SA_OAuthTwitterENGIne *) initOAuthWithDelegate: (NSObject *) delegate 
  {

    if (self = (id) [super initWithDelegate: delegate]) {
       self.requestTokenURL = [NSURL URLWithString: @"https://twitter.com/oauth/request_token"];
       self.accessTokenURL = [NSURL URLWithString: @"https://twitter.com/oauth/access_token"];
       self.authorizeURL = [NSURL URLWithString: @"https://twitter.com/oauth/authorize"];
     }
  return self;
}

修改SA_OAuthTwitterENGIne.m函数.我从@L_489_12@获得了这个链接的帮助.

大佬总结

以上是大佬教程为你收集整理的iphone – Twitter引擎SA_OAuthTwitterEngine集成?全部内容,希望文章能够帮你解决iphone – Twitter引擎SA_OAuthTwitterEngine集成?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。