As the metadata api does not reveal any login you have to use the enterprise/partner login functionality here.
In the current release of the sfAtp-Metadata (15.0.beta) the procedure is a little tricky. Please follow the steps below :
- Download sfatp metadata
- Download sfatp enterprise
- Copy over all files from enterprise directory to metadata directory
- Setup a config-file (be sure to have 'UsePhpSession=true')
- Create a proxy for enterprise and flag to NOT autoinitiate
- call initiateSession(true, 'meta');
- Create a proxy for the metadata
- call $sfMeta->setTns('http://soap.sforce.com/2006/04/metadata');
Please find a complete listing below:
[code]
<?php
require_once '../lib15/metadata/sForce_ServiceProxyEnterprise.php';
require_once '../lib15/metadata/sForce_ServiceProxyMeta.php';
require_once '../lib15/metadata/ListMetadata.php';
require_once '../lib15/metadata/ListMetadataQuery.php';
require_once '../lib15/metadata/ListMetadataResponse.php';
// important, create the Partner-Proxy BEFORE the MetaData-Proxy
// be sure to have UsePhpSession enabled to have the MetaData-Proxy
// and reuse the endpoint and session-id created from the Partner-Proxy
//
// (todo check if this runs also in batch-scenarios / command-line)
$sfLogin = new sForce_ServiceProxyEnterprise('config/sf.config.php', false);
$sfLogin->initiateSession(true, 'meta');
$sfMeta = new sForce_ServiceProxyMeta('config/sf.config.php');
$sfMeta->setTns('http://soap.sforce.com/2006/04/metadata');
$req = new ListMetadata();
$query = new ListMetadataQuery();
$query->setType('CustomObject');
$req->addQueries($query);
$res = $sfMeta->ListMetadata($req);
echo "<pre>". print_r($res, true) . "</pre>";
?>
[/code]
Note: For future releases, we will alter the libs accordently to have the sForce_ServiceProxyMeta acting with a login also. And as such run "out of the box".
regards
Carsten Harnisch
-- InTradeSys Limited