2016-04-13 155 views
1

我使用Postman Chrome擴展來發送帖子並獲取請求並獲取響應。Json響應顯示內容類型文本/ html而不是應用程序/ json

我得到以下響應 -

{ 
    "Myresponse": { 
    "ResponseStatus": 1, 
    "PhoneCount": 3, 
    "Page": "1", 
    "PageSize": "3", 
    "Phones": { 
    "Phone": [ 
    { 
     "AccountSid": "5fd7e139-080c-49ab-bbe4-7c9f686dc64e", 
     "PhoneSid": "5c993989-d8cd-496b-b83c-160023247097", 
     "FriendlyName": "2013554746", 
     "PhoneNumber": "2013554746", 
     "VoiceUrl": null, 
     "VoiceMethod": null, 
     "VoiceFallbackUrl": "", 
     "VoiceFallbackMethod": null, 
     "DateCreated": "2016-04-08 02:27:52", 
     "SMSRequestUrl": null, 
     "SMSMethod": null, 
     "SMSFallbackUrl": null, 
     "SMSFallbackMethod": null, 
     "HeartbeatUrl": "", 
     "HeartbeatMethod": null, 
     "HangupCallback": "", 
     "HangupCallbackMethod": null, 
     "VoiceEnable": "", 
     "SmsEnable": "true", 
     "ApiVersion": "2" 
    }, 
    { 
     "AccountSid": "5fd7e139-080c-49ab-bbe4-7c9f686dc64e", 
     "PhoneSid": "a3b88f36-62d7-49d1-b138-7d6d6c5950b2", 
     "FriendlyName": "2014271285", 
     "PhoneNumber": "2014271285", 
     "VoiceUrl": null, 
     "VoiceMethod": null, 
     "VoiceFallbackUrl": "", 
     "VoiceFallbackMethod": null, 
     "DateCreated": "2016-04-08 02:27:52", 
     "SMSRequestUrl": null, 
     "SMSMethod": null, 
     "SMSFallbackUrl": null, 
     "SMSFallbackMethod": null, 
     "HeartbeatUrl": "", 
     "HeartbeatMethod": null, 
     "HangupCallback": "", 
     "HangupCallbackMethod": null, 
     "VoiceEnable": "", 
     "SmsEnable": "true", 
     "ApiVersion": "2" 
    }, 
    { 
     "AccountSid": "5fd7e139-080c-49ab-bbe4-7c9f686dc64e", 
     "PhoneSid": "670f91f5-b460-4b3b-a0d1-35e742c2a5ef", 
     "FriendlyName": "2014271285", 
     "PhoneNumber": "2014271285", 
     "VoiceUrl": "https://76bvuptovu4g.runscope.net", 
     "VoiceMethod": "GET", 
     "VoiceFallbackUrl": "http://voicefallback.com", 
     "VoiceFallbackMethod": "GET", 
     "DateCreated": "2016-04-08 02:22:41", 
     "SMSRequestUrl": "https://g62ou2lugq56.runscope.net", 
     "SMSMethod": "GET", 
     "SMSFallbackUrl": "https://g62ou2lugq56.runscope.net", 
     "SMSFallbackMethod": "GET", 
     "HeartbeatUrl": "", 
     "HeartbeatMethod": "GET", 
     "HangupCallback": "", 
     "HangupCallbackMethod": "GET", 
     "VoiceEnable": "true", 
     "SmsEnable": "true", 
     "ApiVersion": "2" 
    } 
    ] 
} 
} 
} 

{ 
"Message360": { 
    "ResponseStatus": 1, 
    "PhoneCount": 4, 
    "Page": "1", 
    "PageSize": "4", 
    "Phones": { 
     "Phone": [ 
      { 
       "AccountSid": "5fd7e139-080c-49ab-bbe4-7c9f686dc64e", 
       "PhoneSid": "5c993989-d8cd-496b-b83c-160023247097", 
       "FriendlyName": "2013554746", 
       "PhoneNumber": "2013554746", 
       "VoiceUrl": null, 
       "VoiceMethod": null, 
       "VoiceFallbackUrl": "", 
       "VoiceFallbackMethod": null, 
       "DateCreated": "2016-04-08 02:27:52", 
       "SMSRequestUrl": null, 
       "SMSMethod": null, 
       "SMSFallbackUrl": null, 
       "SMSFallbackMethod": null, 
       "HeartbeatUrl": "", 
       "HeartbeatMethod": null, 
       "HangupCallback": "", 
       "HangupCallbackMethod": null, 
       "VoiceEnable": "", 
       "SmsEnable": "true", 
       "ApiVersion": "2" 
      }, 
      { 
       "AccountSid": "5fd7e139-080c-49ab-bbe4-7c9f686dc64e", 
       "PhoneSid": "a3b88f36-62d7-49d1-b138-7d6d6c5950b2", 
       "FriendlyName": "2014271285", 
       "PhoneNumber": "2014271285", 
       "VoiceUrl": null, 
       "VoiceMethod": null, 
       "VoiceFallbackUrl": "", 
       "VoiceFallbackMethod": null, 
       "DateCreated": "2016-04-08 02:27:52", 
       "SMSRequestUrl": null, 
       "SMSMethod": null, 
       "SMSFallbackUrl": null, 
       "SMSFallbackMethod": null, 
       "HeartbeatUrl": "", 
       "HeartbeatMethod": null, 
       "HangupCallback": "", 
       "HangupCallbackMethod": null, 
       "VoiceEnable": "", 
       "SmsEnable": "true", 
       "ApiVersion": "2" 
      }, 
      { 
       "AccountSid": "5fd7e139-080c-49ab-bbe4-7c9f686dc64e", 
       "PhoneSid": "670f91f5-b460-4b3b-a0d1-35e742c2a5ef", 
       "FriendlyName": "2014271285", 
       "PhoneNumber": "2014271285", 
       "VoiceUrl": "https://76bvuptovu4g.runscope.net", 
       "VoiceMethod": "GET", 
       "VoiceFallbackUrl": "http://voicefallback.com", 
       "VoiceFallbackMethod": "GET", 
       "DateCreated": "2016-04-08 02:22:41", 
       "SMSRequestUrl": "https://g62ou2lugq56.runscope.net", 
       "SMSMethod": "GET", 
       "SMSFallbackUrl": "https://g62ou2lugq56.runscope.net", 
       "SMSFallbackMethod": "GET", 
       "HeartbeatUrl": "", 
       "HeartbeatMethod": "GET", 
       "HangupCallback": "", 
       "HangupCallbackMethod": "GET", 
       "VoiceEnable": "true", 
       "SmsEnable": "true", 
       "ApiVersion": "2" 
      }, 
      { 
       "AccountSid": "5fd7e139-080c-49ab-bbe4-7c9f686dc64e", 
       "PhoneSid": "03488580-5f90-42f6-9ce3-ca801194d763", 
       "FriendlyName": "2019481078", 
       "PhoneNumber": "2019481078", 
       "VoiceUrl": "http://customapps.message360.com/ytel_lead/test_answer.php", 
       "VoiceMethod": "POST", 
       "VoiceFallbackUrl": "", 
       "VoiceFallbackMethod": "POST", 
       "DateCreated": "2016-04-08 02:22:40", 
       "HeartbeatUrl": "", 
       "HeartbeatMethod": "POST", 
       "HangupCallback": "", 
       "HangupCallbackMethod": "POST", 
       "VoiceEnable": "true", 
       "SmsEnable": "false", 
       "ApiVersion": "2" 
      } 
     ] 
    } 
} 
} 

當我檢查既響應的內容類型及其給應用/爲第一和JSONtext/html的第二。

有什麼問題嗎?任何人都可以請幫我嗎?任何幫助將非常感激。

回答

1

嘗試此之前添加這一點,希望這將幫助你..

header("Content-Type: application/json; charset=UTF-8"); 
+1

謝謝埃米爾.. :) – Mohanish

2

如果你長了下面的代碼
響應type..try返回響應

// Set header content 
if($this->requestType == 'xml'){ 
    $this->header('Content-Type', "application/xml; charset=UTF-8"); 
}else{ 
    $this->header('Content-Type', "application/json; charset=UTF-8"); 
} 
+1

謝謝你這麼多。 。 – Mohanish

相關問題