2016-04-13 115 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

相关问题