mercredi 2 mars 2016

Nusoap not working in Laravel 5.1

I am new in laravel , and also in nusop , I have a code which works good in php simple file ( I mean not in laravel ) , but when I want to use it in laravel ,does not work at all !

this is my code :

<?php

require_once "./lib/nusoap.php";
//Parameters    
//

$param  =   array(
                'user_id'   =>  'MY_USERNAME',
                'password'  =>  'MY_PASSWORD',
                'lic_username'  =>  '.......',
                'lic_password'  =>  '.......',
                'debug' =>1);


//Create    object  that    referer a   web services    


$client =   new nusoap_client('http://ift.tt/1QrT9ap' ,true);



//Call  a   function    at  server  and send    parameters  too 
$response   = $client->call("GetLicenseVerification", $param);
//Process   result  
//


if  ($client->fault)    {
                echo    "FAULT: <p>Code:    ("  .   $client->faultcode  .   "</p>";
                echo    "String:    "   .   $client->faultstring;
}   else    {

                if  ($response['error'] ==  '') {
                                //Request   is  Successful
                                //Handle    Response    Data
                                echo    $response['licensekey'];
                                echo    '<br    />';
                                echo    $response['username'];
                                echo    '<br    />';
                                echo    $response['password'];

                                echo    '<br    />';
                                echo    $response['expiration_date'];
                }
                else    {
                                //An    error   occurred
                                //Handle    Error
                                echo    $response['error'];
                }


}
?>

and the output is : test-licensekey test-username test-password 09/29/2015

But I want to use it in Laravel 5.1 .

so I created Libraries directory in app Folder , and put nusoap.php there and renamed it to nusoap_client.php and I have put namespace App\Libraries; in top of it . and I use this in my controller , but out put is null !

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Libraries\nusoap_client;
class NusoapController extends Controller
{

    public function getIndex()
    {
            $param  =   array(
                'user_id'   =>  'MY_USERNAME',
                'password'  =>  'MY_PASSWORD',
                'lic_username'  =>  '.......',
                'lic_password'  =>  '.......',
                'debug' =>1);

//Create    object  that    referer a   web services


        $client =   new nusoap_client('http://ift.tt/1QrT9ap' ,true);



//Call  a   function    at  server  and send    parameters  too
        $response   = $client->call("GetLicenseVerification", $param);
//Process   result
//


        if  ($client->fault)    {
            echo    "FAULT: <p>Code:    ("  .   $client->faultcode  .   "</p>";
            echo    "String:    "   .   $client->faultstring;
        }   else    {

            if  ($response['error'] ==  '') {
                //Request   is  Successful
                //Handle    Response    Data
                echo    $response['licensekey'];
                echo    '<br    />';
                echo    $response['username'];
                echo    '<br    />';
                echo    $response['password'];

                echo    '<br    />';
                echo    $response['expiration_date'];
            }
            else    {
                //An    error   occurred
                //Handle    Error
                echo    $response['error'];
            }


        }
    }

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire