将php代码转换为objectiveC


Convert php code to objectiveC

嗨,我有这个php代码:

$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$quoteId = $proxy->call( $sessionId, 'cart.create');
$arrProducts = array(
    array(
        “product_id” => “1”,
        “qty” => 2
    );
$resultCartProductAdd = $proxy->call(
    $sessionId,
    “cart_product.add”,
    array(
        $quoteId,
        $arrProducts
    )
);

我需要在我的iOS应用程序中使用它,所以我通过使用库来获得sessionIdquoteId。我正在使用的库工作,因此:Magento给了我这个api:customer.create,我必须在customer中设置-创建sessionId和一个数组,我在其中放置客户的详细信息。在objectiveC中,我得到了以下代码:

[Magento call:@[@"customer.create", @{
     @"email": email,
     @"password": password,
     @"firstname": firstname,
     @"lastname": lastname,
     @"website_id": @1,
     @"store_id": Magento.service.storeID
}] success:^(AFHTTPRequestOperation *operation, id responseObject) {
    Magento.service.customerID = responseObject;
    NSLog(@"signUp customerID = %@", Magento.service.customerID);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"error %@", error.localizedDescription);
}];

现在我猜测我的库将php数组转换为NSDictionary(参见上面的代码)。如何在objectiveC中转换数组的php数组(通过使用这个库)?我必须使用cart_product.add magento api。我希望你能理解我的意思,希望你能帮助我。

由我自己解决,代码如下:

[Magento call:@[@"cart_product.add", Magento.service.cartID,@[@{@"product_id": productID, @"qty": self.qty}]]
                        success:^(AFHTTPRequestOperation *operation, id responseObject) {
                            NSLog(@"Prodotto aggiunto");
                            [Magento call:@[@"cart.info", @{@"quoteId": Magento.service.cartID}]
                                  success:^(AFHTTPRequestOperation *operation, id responseObject) {
                                      [self getListOfProductsInCart:responseObject];
                                  }failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                                      NSLog(@"Errore: %@", error.localizedDescription);
                                  }];

用这段代码将您在我的问题中看到的php转换为objectiveC。我希望这对

的人有用