2013-08-29 6 views
5

पर भी पूर्ण प्रतिक्रिया प्राप्त करें क्या file_get_contents बनाना संभव है यदि कोई त्रुटि उत्पन्न होती है तो भी मुझे वास्तविक प्रतिक्रिया दिखाएं?file_get_contents: त्रुटि

अन्यथा डीबग करना मुश्किल है। उदाहरण के लिए, मान लीजिए कि आप निम्नलिखित कोड है:

$url = 'https://api.twitter.com/oauth/request_token'; 
$data = array(); 

$options = array(
    'http' => array(
    'header' => "Content-type: application/x-www-form-urlencoded\r\n", 
    'method' => 'POST', 
    'content' => http_build_query($data), 
    ), 
); 
$context = stream_context_create($options); 
$result = @file_get_contents($url, false, $context); 

var_dump($result); 
var_dump($http_response_header); 

यह मैं परिणाम और HTTP हेडर के लिए शून्य से पता चलता है, लेकिन मैं (Failed to validate oauth signature and token की तरह कुछ होना चाहिए) वास्तविक संदेश ट्विटर वापस भेजता प्राप्त करना चाहते हैं, जो है यदि आप अपने ब्राउज़र में https://api.twitter.com/oauth/request_token लोड करने का प्रयास करते हैं तो आपको क्या मिलता है।

उत्तर

5

संदर्भ के लिए एक बहुत ही सरल स्विच है। बस विकल्प को यह पंक्ति जोड़ें:

'ignore_errors' => true 

ताकि आप

$options = array(
    'http' => array(
    'header' => "Content-type: application/x-www-form-urlencoded\r\n", 
    'method' => 'POST', 
    'content' => http_build_query($data), 
    'ignore_errors' => true 
    ) 
); 
+0

बहुत बढ़िया मिल जाएगा, मुझे उम्मीद थी वहाँ इस तरह स्विच किसी प्रकार का था। – houbysoft

संबंधित मुद्दे