簡體   English   中英

為Joomla將API(xml)/ URL引入php

[英]bringing in an API (xml)/URL into php for Joomla

我需要的是一種將其引入的方法:184.173.18.228/api/profile/1000/0/Adam.Adams(這是一個xml文件)到php中(我以為是),供Joomla使用(我可以使用Sourcerer Joomla中的代碼)-我一直遇到的問題是跨域代理問題-在上周末,我能夠使用Ajax / jquery在該計算機上本地顯示該xml:

// jQuery script

$(function() {
    // Load data from proxy.php using GET request
    $.get('test.xml', function(data)
    {
        // Search for the XML element you want, perform an action on each occurrence of found element
        $(data).find("XMLElement").each(function()
        {
            $('#output').append($(this).attr('XMLAttribute')); // Display desired attribute of element -OR-
            $('#output').append($(this).children("Phone").text());

我什至不確定我是否正確地問了這個問題-我想發生的事情是:引入該xml / url的php腳本,以在頁面上回顯/填充html。 我已經嘗試了上百萬種方法,但無法獲得

確實看起來像Javascript,而不是php。 在php中,無論如何您都沒有跨域限制,因為它運行在服務器而不是瀏覽器上。

所有瀏覽器都將阻止跨域Ajax調用。

您的解決方案是用php編寫一個腳本,該腳本對遠程站點執行wget或curl操作,因此您調用本地腳本,服務器上的腳本將加載遠程URL。 您應該能夠找到一些現成的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM