0
使用curl与api标记并将XML元素获取到工作变量或至少以html格式查看。Highrise API - 如何使用XML并操作变量
这里使用的是做了vardump代码:
$curl = curl_init('https://mywebsite.highrisehq.com/people.xml');
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl,CURLOPT_USERPWD,'myapitoken12345:x');
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,0);
$data = curl_exec($curl);
curl_close($curl);
$people_xml = new SimpleXMLElement($data);
var_dump($people_xml);
当做的var_dump,输出是不是我所熟悉的。
object(SimpleXMLElement) #1 (2) {
["@attributes"]=> array(1) {
["type"]=> string(5) "array" }
["person"]=> array(128) { ... etc. etc. etc...
HighriseHQ.com显示的XML结构就像这样用于获取元素的线索。
<people type="array">
<person>
<first-name>John</first-name>
</person>
<person>
<first-name>Jane</first-name>
</person>
</people>
.... etc. etc.
如何或在哪里将$people = simplexml_load_string($xml);
的部分转换为我可以使用的变量?最终,我想要显示,编辑或存储这些人,因为我将同步网站数据库与高层 - 使笔记和联系人不过时。