lukebeer / broadworks-ocip

PHP Framework for interacting with the Broadworks OCI Provisioning API
GNU General Public License v2.0
26 stars 15 forks source link

How to access/get serviceProviderId after login #15

Closed xciser77 closed 4 years ago

xciser77 commented 7 years ago

After login I like to get the serviceProviderID because it is needed for some/many request. I can find the spid after login with $client->getResponse(), but it is protected so i cannot get the value.

How can I get the serviceproviderid after login ? Code I use is: $client = Factory::getSOAPClient('serveradres); $client->login('username','password');

    $connectinfo = $client->getResponse();

In the above code I removed the server/username/password

TwinMist commented 7 years ago

You will need to do a UserGetLoginInfoRequest, then in the UserGetLoginInfoResponse will return

lukebeer commented 4 years ago

$serviceProviderId will be the service provider ID result or null.

<?php
require_once 'vendor/autoload.php';

use BroadworksOCIP\api\Rel_17_sp4_1_197_OCISchemaAS\OCISchemaLogin\UserGetLoginInfoRequest;

$client = BroadworksOCIP\Factory::getSOAPClient('ocip.example.com');
if ($client->login('user', 'pass')) {
    $request = new UserGetLoginInfoRequest();
    $serviceProviderId = $request->get($client)->getServiceProviderId();
    $client->logout();
}
?>