gpt4 book ai didi

iphone - 如何在 Iphone 中调用 Magento API 登录方法

转载 作者:行者123 更新时间:2023-11-28 22:35:23 26 4
gpt4 key购买 nike

任何人都可以告诉我如何在 iphone 中调用 megnto api 的登录方法我已经使用 xmlrpc 库在 andriod 中完成了

// ...
String sessionId = "";
//HashMap<string , String> params = new HashMap</string><string , String>();
//params.put("apiUser", "developer");
//params.put("apiKey", "magento123");
XMLRPCClient client = new XMLRPCClient("http://some-site.com/index.php/api/xmlrpc/");
try {
/*
sessionId = (String)client.callEx("login", new Object[]{params});
will cause
DEBUG/MY_XMLRPCException_MSG(196): XMLRPC Fault: Calling parameters do not match signature 1
*/
sessionId = (String)client.call("login", "developer", "magento123");
Log.d("MY_XMLRPC_SUCCESS_SESSION_ID", sessionId);
}
catch (XMLRPCException e) {
Log.d("MY_XMLRPCException_MSG", e.getMessage());
}

我是 iphone 的新手,我如何在 iphone 中做任何人都可以告诉我的图书馆或例子,引导我做我想做的事!!!

最佳答案

我得到了解决方案,我正在使用来自 git hub 的 AFNetworking 库,我正在使用以下库在以下链接中给出 https://github.com/lognllc/LogNMagento

一些基本步骤

=> 在您的应用程序中导入 LogNMangento 应用程序

=> 在 magento.h 中 - (void)settingLogin:(completionBlock) completionBlock;

=> 在 magento.m 中

- (void)settingLogin:(completionBlock)completionBlock
{

standardUserDefaults = [NSUserDefaults standardUserDefaults];
array =[standardUserDefaults objectForKey:@"Prefs"];

client = [[MagentoClient alloc] initWithBaseURL:[NSURL URLWithString:[array objectAtIndex:0]]];
[client setDefaultHeader:@"SOAPAction" value:@"urn:Mage_Api_Model_Server_HandlerAction"];
[client registerHTTPOperationClass:[SoapRequestOperation class]];
[SoapRequestOperation addAcceptableStatusCodes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 301)]];
[client setDefaultHeader:@"Content-Type" value:@"text/xml; charset=utf-8"];
[client postPath:@"login" parameters:@{@"username":[array objectAtIndex:1], @"apiKey": [array objectAtIndex:2] } success:^(AFHTTPRequestOperation *operation, id responseObject) {
sessionID = responseObject;
completionBlock(sessionID);
} failure:^(AFHTTPRequestOperation *operationData, NSError *error) {
NSLog(@"Response is not get");
sessionID = FAILED_SESSION;
completionBlock(sessionID);
}];

}

=> 在你的类里面调用它

[Magento.service settingLogin:^(NSString *session) {
if(session){

NSLog(@"Session %@",session);
if(![session isEqualToString:@"NULL"])
{
[self.view hideToastActivity];


self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
[self.navigationController pushViewController:self.viewController animated:YES];
}
else
{
[self.view hideToastActivity];
[self.view makeToast:@"Please Check Store Info"];
session=nil;
}
}
else{

}
}];
}
else
{
[self.view makeToast:@"Please insert data"
duration:1.0
position:@"bottom"
];
}

是的,还对基本 url 中的 magento.m 的 INIT 进行了一些更改

关于iphone - 如何在 Iphone 中调用 Magento API 登录方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16212696/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com