2012-03-01 2 views

답변

3

예, 가능합니다. eBay API. 당신은 처음 부분을 소비하고 그것으로 작업해야 할 것입니다.

+0

감사합니다. 하지만 우리는 eBay SDK를 사용하기 전에 이베이 SDK를 프로젝트에 가져와야한다고 생각합니다. 따라서 iOS 용 eBay SDK를 찾을 수 없었습니다. iOS 용 eBay sdk가 없으면 iOS 프로젝트에서 eBay API를 어떻게 사용할 수 있습니까? 동일한 대안에 대한 대안이 있다면 알려 주시기 바랍니다 .. – vipsk

+0

@ S.P. 맞아. 구매자 용 응용 프로그램을 설계하는 경우 REST를 사용할 수 있습니다. 판매자 용으로 설계하는 경우 SOAP을 사용할 수 있습니다. REST 및 SOAP 서비스를 사용할 수 있도록 도와주는 타사 iOS 라이브러리가 있습니다. eBay 브랜드의 iOS SDK는 필요하지 않습니다 (존재하지 않습니다). – devlord

1

iPhone에서 eBay API를 사용하는 예를 찾을 수 없으므로 iOS 프로젝트에서 이베이 찾기 API를 사용하는 예를 찾고있는 사용자에게 도움이되기를 바랍니다.

다음은 "harry" "potter" "phoenix"키워드에 대한 JSON 데이터를 반환하는 간단한 GET 요청입니다. [YOUR APP ID]를 ebay 앱 ID로 바꿉니다.

@interface BGSEbayTest : NSObject <NSURLConnectionDelegate, NSURLSessionDelegate> 
- (void)listEBayItems:(NSDictionary *)dictData; 
@end 

.

#import "BGSEbayTest.h" 

@interface BGSEbayTest() 
@property (strong, nonatomic) NSURLConnection *connection; 
@property (strong, nonatomic) NSMutableData *receivedData; 

@end 


@implementation BGSEbayTest 

- (void)listEBayItems:(NSDictionary *)dictData { 

    self.receivedData = [[NSMutableData alloc]init]; 

    //dictData is going to be used to set the search keywords BUT, for demo, its hard-coded to harry potter phoenix 

    NSString *strURL = @"http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&SECURITY-APPNAME=[YOUR APP ID]&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD&keywords=harry%20potter%20phoenix"; 

    NSURL *url = [NSURL URLWithString:strURL]; 
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 
    //initialize a connection from request 
    NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; 
    self.connection = connection; 
    [connection start]; 
} 



-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ 
// NSString* strData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 
// NSLog(@"DEBUG didReceiveData string: %@" , strData); 

    [self.receivedData appendData:data]; 
} 
/* 
if there is an error occured, this method will be called by connection 
*/ 
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{ 

    NSLog(@"%@" , error); 
} 

/* 
if data is successfully received, this method will be called by connection 
*/ 
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{ 
    NSLog(@"DEBUG : %@" , @"connectionDidFinishLoading"); 
    NSString* strData = [[NSString alloc] initWithData:self.receivedData encoding:NSUTF8StringEncoding]; 
    NSLog(@"%@" , strData); 
    } 
@end 

이를 실행하려면 다음 링크에 대한

BGSEbayTest *ebayFinder = [[BGSEbayTest alloc]init]; 
    [ebayFinder listEBayItems:nil]; 
+0

이 요청을 eBay에 게시 할 때 상태 500을 얻으십시오. 오류와 데이터 모두 되돌아오고 있습니다. –

관련 문제