因此,我正在嘗試爲我的web應用程序開發一個模塊,它使用PHP cURL將內容提要推送到我們的Google Search Appliance(GSA)通過端口19900將數據作爲POST信息發送到設備。基於我在創建和向GSA提交Feed的文檔中閱讀的所有內容,這應該沒有問題,但服務器正在返回以下(令人難以置信模糊,主要是無用的)錯誤:使用PHP cURL提交Google Search Appliance(GSA)內容提要 - 400錯誤
- That's an error.
Your client has issued a malformed or illegal request. That's all we know.
我已經與誰幫儀器GSA我們的姊妹網站建築師解決此,我們也無法確定是什麼原因造成我們的問題。根據我們的IT部門,所有端口都會打開以便進行通信(如果關閉,我們不會收到錯誤消息),並且我們已驗證發送服務器的IP地址被列爲「允許」在GSA中。不用說,我們很難過。
這裏是傳輸XML飼料代碼:
<?php
$target_url = 'http://gsadomain.com:19900/xmlfeed';
$header = array('Content-Type: multipart/form-data');
$fields = array(
'feedtype'=>'incremental',
'datasource'=>'datasourcename',
'data'=>'@'.realpath('gsa_feed.xml')
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, "gsaadmin:gsaadminpassword");
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_TIMEOUT,120);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
$return = curl_exec($ch);
if (curl_errno($ch)) {
$msg = curl_error($ch);
}
curl_close ($ch);
echo $return;
?>
這裏是我們正在試圖提交XML:
基於我們所看到的一切<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE gsafeed PUBLIC "-//Google//DTD GSA Feeds//EN" "http://this.is.the.ip/gsafeed.dtd">
<gsafeed>
<header>
<datasource>datasource</datasource>
<feedtype>incremental</feedtype>
</header>
<group>
<record url="http://website.com/mod/view.php?id=15903" mimetype="text/html" last-modified="Thu, 14 Aug 2014 18:53:00 GMT">
<acl inheritance-type="and-both-permit">
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">customers</principal>
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">partners</principal>
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">employees</principal>
</acl>
<metadata>
<meta name="type" content="module" />
<meta name="id" content="1" />
<meta name="name" content="Module for Everyone" />
<meta name="course_id" content="655" />
</metadata>
<content>
This is the description of the Module for Everyone.
</content>
</record>
<record url="http://website.com/mod/view.php?id=15904" mimetype="text/html" last-modified="Thu, 14 Aug 2014 18:53:00 GMT">
<acl inheritance-type="and-both-permit">
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">employees</principal>
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">partners</principal>
</acl>
<metadata>
<meta name="type" content="module" />
<meta name="id" content="2" />
<meta name="name" content="Module for Partners" />
<meta name="course_id" content="655" />
</metadata>
<content>
This is the description of the Module for Partners.
</content>
</record>
<record url="http://website.com/mod/view.php?id=15905" mimetype="text/html" last-modified="Thu, 14 Aug 2014 18:53:00 GMT">
<acl inheritance-type="and-both-permit">
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">employees</principal>
</acl>
<metadata>
<meta name="type" content="module" />
<meta name="id" content="3" />
<meta name="name" content="Module for Employees" />
<meta name="course_id" content="655" />
</metadata>
<content>
This is the description of the Module for Employees.
</content>
</record>
<record url="http://website.com/course/view.php?id=655#section-1" mimetype="text/html" last-modified="Thu, 14 Aug 2014 18:53:00 GMT">
<acl inheritance-type="and-both-permit">
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">customers</principal>
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">partners</principal>
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">employees</principal>
</acl>
<metadata>
<meta name="type" content="topic" />
<meta name="id" content="1" />
<meta name="name" content="Course Topic for Everyone" />
<meta name="course_id" content="655" />
</metadata>
<content>
This is the description of the Course Topic for All Audiences.
</content>
</record>
<record url="http://website.com/course/view.php?id=655#section-2" mimetype="text/html" last-modified="Thu, 14 Aug 2014 18:53:00 GMT">
<acl inheritance-type="and-both-permit">
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">employees</principal>
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">partners</principal>
</acl>
<metadata>
<meta name="type" content="topic" />
<meta name="id" content="2" />
<meta name="name" content="Course Topic for Partners" />
<meta name="course_id" content="655" />
</metadata>
<content>
This is the description of the Course Topic for Partners.
</content>
</record>
<record url="http://website.com/course/view.php?id=655#section-3" mimetype="text/html" last-modified="Thu, 14 Aug 2014 18:53:00 GMT">
<acl inheritance-type="and-both-permit">
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">employees</principal>
</acl>
<metadata>
<meta name="type" content="topic" />
<meta name="id" content="3" />
<meta name="name" content="Course Topic for Employees" />
<meta name="course_id" content="655" />
</metadata>
<content>
This is the description of the Course Topic for Employees.
</content>
</record>
<record url="http://website.com/course/view.php?id=655" mimetype="text/html" last-modified="Thu, 14 Aug 2014 18:53:00 GMT">
<acl inheritance-type="and-both-permit">
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">customers</principal>
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">partners</principal>
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">employees</principal>
</acl>
<metadata>
<meta name="type" content="course" />
<meta name="id" content="655" />
<meta name="name" content="Course for Everyone" />
<meta name="course_id" content="655" />
</metadata>
<content>
This is the description of the Course for Everyone.
</content>
</record>
<record url="http://website.com/course/view.php?id=656" mimetype="text/html" last-modified="Thu, 14 Aug 2014 18:53:00 GMT">
<acl inheritance-type="and-both-permit">
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">employees</principal>
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">partners</principal>
</acl>
<metadata>
<meta name="type" content="course" />
<meta name="id" content="656" />
<meta name="name" content="Course for Partners" />
<meta name="course_id" content="656" />
</metadata>
<content>
This is the description of the Course for Partners.
</content>
</record>
<record url="http://website.com/course/view.php?id=657" mimetype="text/html" last-modified="Thu, 14 Aug 2014 18:53:00 GMT">
<acl inheritance-type="and-both-permit">
<principal scope="group" access="permit" namespace="Default" case-sensitivity-type="everything-case-insensitive">employees</principal>
</acl>
<metadata>
<meta name="type" content="course" />
<meta name="id" content="657" />
<meta name="name" content="Course for Employees" />
<meta name="course_id" content="657" />
</metadata>
<content>
This is the description of the Course for Employees.
</content>
</record>
</group>
</gsafeed>
,這應該工作,但我們卻遇到了一堵磚牆。有沒有人有任何想法?
作爲補充說明,由於我們試圖建立索引的頁面的設置方式,使設備抓取頁面不起作用(交互元素太多,而且我讀過的所有內容都表明, GSA無法正確編制索引)。
編輯1:正如馬克在答覆建議,這裏是鏈接到GSA飼料開發人員指南:http://www.google.com/support/enterprise/static/gsa/docs/admin/72/gsa_doc_set/feedsguide/feedsguide.html
編輯2:成功!請參閱下面的答案。關鍵是讓cURL處理$ fields數組的編碼,並傳遞文件內容,而不僅僅是文件路徑。
我剛剛給了這個鏡頭,並沒有任何運氣。有問題的PHP腳本構建了xml文件,所以最初,我只是將我寫入的字符串包含爲'$ fields = array('fieldtype'=>'incremental','datasource'=>'datasourcename','數據 '=> $串);'如果這樣做不起作用,我切換到@ path/to/gsa_feed.xml方法(儘管你提出的建議可能是我想要的,因爲我在文檔中看到了這些內容。 – 2014-09-24 20:06:06
@JoshC你可以鏈接API文檔在你的問題中,從你顯示的PHP中,沒有什麼地方會建立一個XML文件,你顯示的只是一個簡單的cURL POST,只有幾個字段的數據,其中一個是這個字符串。 – 2014-09-24 21:33:42
@Mark Brant我剛剛編輯原始帖子以包含Google的開發人員指南鏈接,不幸的是,它並沒有給你提供太多的指導。 Feed腳本,再次點擊此鏈接:http://www.google.com/support/enterprise/static/gsa/docs/admin/72/gsa_doc_set/feedsguide/feedsguide.html – 2014-09-25 12:59:26