2017-03-01 67 views
1

我得到一個奇怪的錯誤與PHP的JSON輸出設置有效的字符集:無法爲禮品卡獎勵JSON輸出

無效編碼,預計UTF-8,UTF-16和UTF-32。 [代碼29, 結構0]

我嘗試添加這頭如下,但到目前爲止沒有運氣:

header('Content-type: application/json;charset=utf-8'); 

從這個工具返回:https://jsonformatter.curiousconcept.com

JSON供稿位於:

https://www.pointsprizes.com/api/mobile/account/prizes/123132

嘗試一切我能想到的,試圖將其設置爲16,然後32,仍然沒有運氣。任何想法是什麼問題?

+0

我將刪除charset = utf-8設置,以便您可以看到輸出內容 –

+0

感謝大家的幫助。現在,我的所有用戶都可以從API中看到他們的免費禮品卡獎品:) –

回答

2

艾米檢查該響應:

{"status":"success","reason":"","device":"","version":"","email":"[email protected]","id":"123132","points":"1502","offers":"true","hyprmx":"true","prizes":"true","visit":"true","html":"<!doctype html><html lang='en'><head></head><body><p style='font-weight:900;'>received account_id: 123132</p><p>received device: </p><p>received version: </p></body></html>"} 

HTML是也存在於這樣的:

<!doctype html><html lang='en'><head></head><body><p style='font-weight:900;'>received account_id: 123132</p><p>received device: </p><p>received version: </p></body></html> 

因爲這個網站的,與json_decode()它顯示:

<br /> 
<b>Parse error</b>: syntax error, unexpected 'en' (T_STRING), expecting ',' or ')' in <b>[...][...]</b> on line <b>3</b><br /> 

當我刪除它並json_decode()它,它給:

stdClass Object 
(
    [status] => success 
    [reason] => 
    [device] => 
    [version] => 
    [email] => [email protected] 
    [id] => 123132 
    [points] => 1502 
    [offers] => true 
    [hyprmx] => true 
    [prizes] => true 
    [visit] => true 
    [html] => 
) 
+0

我正在使用的應用程序開發人員正在尋求html ....我如何包含它? –

+0

選中此:http://sandbox.onlinephpfunctions.com/code/d3675041fa2c7ccc29c2d61a861a69c1f2d9d1a6 –

+1

問題在這裏:lang ='en'。這裏字符串沒有正確連接。 –