0

我正在使用 Salesforce 元数据 API。我得到一个 base64 数据,其中包含一个项目清单,一个名为package.xml. 如何package.xml从此数据中获取文件。

请参阅下面的编码数据:

UEsDBBQACAAIAOcycUEAAAAAAAAAAAAAAAAhAAAAdW5wYWNrYWdlZC9vYmplY3RzL0NvbnRhY3Qub2JqZWN01Vffb9owEH7nr4jyPpxO0zRNIRWlVKDxS5CNR2SSC/FwHGo7tPnv65CAE0CoUFYxnnKfz+fvvrtLjH3/GlFjDVyQmDXMu7plGsC82Cds0TB/u09ffpj3Ts1uJULG0XD+FzxpqC1MNMxQytVPhESMV3URxNyDuhdH6KtlfUfWNxSBxD6W2HRqhvrZwPCcwhOALxzJE7BRGcl9AgJ0a+RAQukAR+D0MFskeAFiNvNstIO1J7xK4AzTru8EmIosvEa0G8VzoDqajXKg5ABsIUPnzrLUWv6sFzk8J4TD7oidrV0kx94yy6lDlGQ83boe4KUt6QocV9FVXtmjXkkYeU5gG6KwcqlQWatTwgH2J3GiqnNUthXxllQx0lAF/oNpAqK6WI0/hfmxwDtHHwKcULnNYWtWj0OnzjuDzCiMGRhdllUlvSFamEsG3BhDAJxjekPMVGOEWIBv9JT/7fAayhD4v6YjYi71LBdW7XDz/qiOCrw8rmfM4xrodV5iWaTDF9iHJ3oCXsx8fEsD5AKX5KYYjTiJPoHQJS164QfoHV29oUng5WhjNyltxUxiT4qjvR0Qqlp54sUqeFvdOFIZqktGdoLG91tcxTR00FKnK6PK5TS3B8Jl6ONUuCERfRUwvALFHN2v2EYwpzUcuM2WW3/ojt3OY9NtF0ruOauAHEt19XLURUKVyUYaqXqus+5w3E53Muur2B0b5UipFw74FCLukjey7I0i/cvF7KfvrnOfMDhd4X56lQIP4KWHhZwCLD+psq1xW5X1cXa94vaaE3c2bbd/nVFblbeRJW7kmX9IwKw7/msBN9NxgYCbsTgtoI3K/4Cc2htQSwcIRtMK5HUCAAA4DQAAUEsDBBQACAAIAOcycUEAAAAAAAAAAAAAAAAWAAAAdW5wYWNrYWdlZC9wYWNrYWdlLnhtbE2OzQrCMBCE732KkLvZWKSIpOmh4FUP+gBpumrVJKVZRd/e2h90TzPDx+yo4uXu7IldbILP+VJIztDbUDf+nPPjYbtY80Inam/szZyR9bSPOb8QtRuAGEwr4il0FoUNDlIpM5ArcEimNmS4Tlh/it4txlEP3qGr+pe6DJ6MJQVz8EO8cajLR6TgdtUVv9AQjYXw16im9TrNhFQwu0TBNFonH1BLBwj45N4QogAAAOYAAABQSwECFAAUAAgACADnMnFBRtMK5HUCAAA4DQAAIQAAAAAAAAAAAAAAAAAAAAAAdW5wYWNrYWdlZC9vYmplY3RzL0NvbnRhY3Qub2JqZWN0UEsBAhQAFAAIAAgA5zJxQfjk3hCiAAAA5gAAABYAAAAAAAAAAAAAAAAAxAIAAHVucGFja2FnZWQvcGFja2FnZS54bWxQSwUGAAAAAAIAAgCTAAAAqgMAAAAA

我正在使用 base64_decode() 方法,但我得到如下输出:

PKç2qA!unpackaged/objects/Contact.objectÕWßoÚ0~篈ò>œNÓ4M!¥T ñKGd’ñpj;´ùïë€@¨PV1žrŸÏçï¾»KŒ}ÿQc \˜5Ì»ºeÀ¼Ø'lÑ0»O_~˜÷NÍn%BÆÑpþ–Øtj†úÙÀðœÂ€/É°QÉ}tkä@BéGàô0[$xb6ól´ƒµ'¼JàӮ,¼F´Ås :šr äl!CçβÔZþ¬9<'„Ã]$ÇÞ2Ë©C”d<ݺà¥-é WÑU^Ù£^IyN`¢°r©PY«SÂö'q¢ªsT¶ñ–T1ÒPþƒi¢ºX?…ù±À;GœP¹ÍakVC§Î;ƒÌ(Œ]–U%½!Z˜KÜCœczCÌTc„X€oô”ÿíðÊø¿¦#b.õ,Vípóþ¨Ž ¼<®gÌãèu^bY¤Ã؇'z^Ì||Kä—ä¦8‰&gt;Ð%-záè]½¡Iàåhc7)mÅLbOŠ£½ªZyâÅ*x[Ý8RªKFv‚Æ÷[\Å4tÐR§+£Êå4·ÂeèãT¸!}0¼ÅݯØF0§5¸Í–[èŽÝÎcÓmJî9«€KuõrÔEB•ÉF©z®³îpÜNw2ë«ØåH©ø"î’7²ì"ýËÅì§ï®sŸ08]á~z•à¥‡…œ,?©²­q[•õqv½âöšw6m·Q[•·‘%nä™HÀ¬;þk7Óq€›±8- Êÿ€œÚPKFÓ äu8 PKç2qAunpackaged/package.xmlMŽÍ Â0„ï}Š»ÙX¤ˆ¤é¡àUúiºjÕ$¥YEßÞÚtO3ÃÇì¨âåîì‰]l‚ÏùRHÎÐÛP7þœóãa»XóB'joìÍœ‘õ´9¿µ€L+â)t… R)3+pH¦6d¸NXŠÞ-ÆQÞ¡«ú—ºžŒ%sðC¼q¨ËG¤àvÕ¿Ð…ðר¦õ:Í„T0»DÁ4Z'PKøäÞ¢æPKç2qAFÓ äu8 !unpackaged/objects/Contact.objectPKç2qAøäÞ¢æÄunpackaged/package.xmlPK“ª
4

1 回答 1

2

我试过这段代码:

<?php
header('Content-Type: application/zip');
header('Content-disposition: filename="my.zip"');
$s = "UEsDBBQACAAIAOcycUEAAAAAAAAAAAAAAAAhAAAAdW5wYWNrYWdlZC9vYmplY3RzL0NvbnRhY3Qub2JqZWN01Vffb9owEH7nr4jyPpxO0zRNIRWlVKDxS5CNR2SSC/FwHGo7tPnv65CAE0CoUFYxnnKfz+fvvrtLjH3/GlFjDVyQmDXMu7plGsC82Cds0TB/u09ffpj3Ts1uJULG0XD+FzxpqC1MNMxQytVPhESMV3URxNyDuhdH6KtlfUfWNxSBxD6W2HRqhvrZwPCcwhOALxzJE7BRGcl9AgJ0a+RAQukAR+D0MFskeAFiNvNstIO1J7xK4AzTru8EmIosvEa0G8VzoDqajXKg5ABsIUPnzrLUWv6sFzk8J4TD7oidrV0kx94yy6lDlGQ83boe4KUt6QocV9FVXtmjXkkYeU5gG6KwcqlQWatTwgH2J3GiqnNUthXxllQx0lAF/oNpAqK6WI0/hfmxwDtHHwKcULnNYWtWj0OnzjuDzCiMGRhdllUlvSFamEsG3BhDAJxjekPMVGOEWIBv9JT/7fAayhD4v6YjYi71LBdW7XDz/qiOCrw8rmfM4xrodV5iWaTDF9iHJ3oCXsx8fEsD5AKX5KYYjTiJPoHQJS164QfoHV29oUng5WhjNyltxUxiT4qjvR0Qqlp54sUqeFvdOFIZqktGdoLG91tcxTR00FKnK6PK5TS3B8Jl6ONUuCERfRUwvALFHN2v2EYwpzUcuM2WW3/ojt3OY9NtF0ruOauAHEt19XLURUKVyUYaqXqus+5w3E53Muur2B0b5UipFw74FCLukjey7I0i/cvF7KfvrnOfMDhd4X56lQIP4KWHhZwCLD+psq1xW5X1cXa94vaaE3c2bbd/nVFblbeRJW7kmX9IwKw7/msBN9NxgYCbsTgtoI3K/4Cc2htQSwcIRtMK5HUCAAA4DQAAUEsDBBQACAAIAOcycUEAAAAAAAAAAAAAAAAWAAAAdW5wYWNrYWdlZC9wYWNrYWdlLnhtbE2OzQrCMBCE732KkLvZWKSIpOmh4FUP+gBpumrVJKVZRd/e2h90TzPDx+yo4uXu7IldbILP+VJIztDbUDf+nPPjYbtY80Inam/szZyR9bSPOb8QtRuAGEwr4il0FoUNDlIpM5ArcEimNmS4Tlh/it4txlEP3qGr+pe6DJ6MJQVz8EO8cajLR6TgdtUVv9AQjYXw16im9TrNhFQwu0TBNFonH1BLBwj45N4QogAAAOYAAABQSwECFAAUAAgACADnMnFBRtMK5HUCAAA4DQAAIQAAAAAAAAAAAAAAAAAAAAAAdW5wYWNrYWdlZC9vYmplY3RzL0NvbnRhY3Qub2JqZWN0UEsBAhQAFAAIAAgA5zJxQfjk3hCiAAAA5gAAABYAAAAAAAAAAAAAAAAAxAIAAHVucGFja2FnZWQvcGFja2FnZS54bWxQSwUGAAAAAAIAAgCTAAAAqgMAAAAA";
$out = base64_decode($s);
print($out);
?>

浏览器会下载一个包含 .xml 文件的工作 ZIP 文件。

如果您想使用 PHP 处理该 ZIP 文件的内容,您可以启用 php_zip 扩展并查看以下答案:Unzip a file with php

于 2012-11-17T07:22:21.527 回答