access Web API PHP and NuSOAP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tietram
    New Member
    • Mar 2008
    • 1

    #1

    access Web API PHP and NuSOAP

    hi i also have some problem to access web api
    my api taking arguments as an array but the correct request is not generated my code is like this[php]<?php
    set_time_limit( 3*60);
    /*
    * $Id: wsdlclient1.php ,v 1.3 2007/11/06 14:48:48 snichol Exp $
    *
    * WSDL client sample.
    *
    * Service: WSDL
    * Payload: document/literal
    * Transport: http
    * Authentication: none
    */
    require_once('. ./lib/nusoap.php');
    echo "vinay55";
    $proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
    $proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
    $proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
    $proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
    $client = new nusoap_client(' http://api.payloadz.co m/payloadzws.asmx ?WSDL', 'wsdl',
    $proxyhost, $proxyport, $proxyusername, $proxypassword) ;
    echo "vinay56";
    $err = $client->getError();
    echo "vinay57";
    if ($err) {
    echo '<h2>Constructo r error</h2><pre>' . $err . '</pre>';
    }

    /* REQUIRED PARAMETER */
    echo "vinay58";
    $username ="PL_API_FAD309 46AC021BBD374DB 4CF0F27AB21";
    $password = "shyam";
    $signature = "1AE78E32391B4A C70F0F492717D88 F48FAD30946AC02 1BBD374DB4CF0F2 7AB21";
    echo "vinay59";
    //$item_number[] =array('item_nu mber1'=>'nv2',' item_number2'=> 'nv1');
    //$item_name[] = array('string'= >'nov2','string '=>'nov1');
    //$item_price[] =array('double' => 10.00,'double'= > 10.00);
    //$quantity[] = array('int'=>2, 'int'=>2);
    $item_number =array('nv2','n v1');
    $item_name = array('nov2','n ov1');
    $item_price =array(10.00,10 .00);
    $quantity = array(2,2);
    //$item_number1 =array('i_numbe r' => $item_number);
    //$item_name1 = array('i_name' => $item_name);
    //$item_price1 =array('i_price ' => $item_price);
    //$quantity1 = array('i_quanti ty' => $quantity);
    echo "vinay66";
    $mc_gross = "20.00";
    $mc_currency = "USD";
    $payer_email = "shyam@econnois seur.com";
    $flag_txn_id = "false"; /*/////// NOT GENERATE NEW TXT_ID, */
    $txn_id="NDUBXI KNGRIGGKZKTQLF" ;
    /* OPTIONAL PARAMETERS */
    $business="";
    $mc_fee="0.00";
    $invoice="";
    $receipt_id="";
    $custom="";
    $settle_amount= "0";
    $settle_currenc y="";
    $exchange_rate= "0";
    $first_name="";
    $last_name="";
    $address_street ="";
    $address_status ="";
    $address_city=" ";
    $address_state= "";
    $address_zip="" ;
    $address_countr y="";
    $address_countr y_code="";
    $param = array('APIusern ame' => $username, 'APIpassword' => $password, 'APIsignature' => $signature,'ite m_number' =>$item_number, 'item_name' =>$item_name,
    'item_price'=>$ item_price, 'quantity'=>$qu antity, 'mc_gross'=>$mc _gross, 'mc_currency'=> $mc_currency, 'payer_email'=> $payer_email, 'flag_txn_id'=> $flag_txn_id,
    'txn_id'=>$txn_ id, 'business'=>$bu siness,'mc_fee' =>$mc_fee,'invo ice'=>$invoice, 'receipt_id'=>$ receipt_id, 'custom'=>$cust om, 'settle_amount' =>$settle_amoun t, 'settle_currenc y'=>$settle_cur rency, 'exchange_rate' =>$exchange_rat e, 'first_name'=>$ first_name, 'last_name'=>$l ast_name, 'address_street '=>$address_str eet,
    'address_status '=>$address_sta tus, 'address_city'= >$address_cit y, 'address_state' =>$address_stat e, 'address_zip'=> $address_zip, 'address_countr y'=>$address_co untry, 'address_countr y_code'=>$addre ss_country_code );
    echo "vinay61";
    // print_r ($param);
    $vinayres=$clie nt->getHTTPBody( );
    echo $vinayres;
    //calling web sevices
    $result = $client->call('Transact ionCreation', array('paramete rs' => $param), '', '', false, true);
    echo "vinay62";
    echo '<h2>Request</h2><pre>' . htmlspecialchar s($client->request, ENT_QUOTES) . '</pre>';
    echo '<h2>Response</h2><pre>' . htmlspecialchar s($client->response, ENT_QUOTES) . '</pre>';
    // Check for a fault
    if ($client->fault) {
    echo '<h2>Fault</h2><pre>';
    print_r($result );
    echo '</pre>';
    } else {
    // Check for errors
    $err = $client->getError();
    if ($err) {
    // Display the error
    echo '<h2>Error</h2><pre>' . $err . '</pre>';
    } else {
    // Display the result

    echo '<h2>Result</h2>';
    print_r($result['TransactionCre ationResult']);
    }
    echo '<h2>Request</h2><pre>' . htmlspecialchar s($client->request, ENT_QUOTES) . '</pre>';
    echo '<h2>Response</h2><pre>' . htmlspecialchar s($client->response, ENT_QUOTES) . '</pre>';
    }
    //echo '<h2>Debug</h2><pre>' . htmlspecialchar s($client->debug_str, ENT_QUOTES) . '</pre>';
    ?>[/php]

    Please enclose any code within the proper code tags. See the Posting Guidelines on how to do that.

    MODERATOR
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    You are not allowed to 'break in' into a thread with your own new problem. Therefore that post has been split off and continues in this thread.

    Read the Posting Guidelines before you continue in this forum, also regarding the use of code tags around shown code and samples.

    moderator

    Comment

    Working...