|  | 
	                
  
    | 
	 
        curl มันดึงข้อมูลไม่ได้ แต่พอปริ้น url แล้วเอาไปเข้าตรงๆ กับได้มีข้อมูล อาการแบบนี้มันเป็นเพราะอะไร ช่วยหน่อยครับ     |  
    |  |  
 
              
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ลองเพิ่ม curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); เข้าไปดูครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2016-08-11 14:28:20 | By :
                            adaaugusta |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ผมลองเพิ่ม curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); ตามที่บอกแล้ว พอ var_dump ผลมันก็ได้ bool(false) เหมือนเดิมเลย 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2016-08-11 14:56:20 | By :
                            funrun |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | งั้นลองเพิ่ม 
 curl_setopt( $ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
 
 หน่อยครับ
 
 |  
              | 
 ประวัติการแก้ไข
 2016-08-11 15:08:30
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2016-08-11 15:05:00 | By :
                            adaaugusta |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
//$response = curl_exec($ch);
//if(curl_exec($ch) === false){
//    echo "error: " . curl_error($ch)."<br>";
//}else{
//    echo "Operation completed without any errors<br>";
//}
curl_close($ch);
var_dump($response);
 ผมลองทำเพิ่มเป็นแบบนี้ ผลยังเป็น bool(false) ครับ
 
 |  
              | 
 ประวัติการแก้ไข
 2016-08-11 15:21:46
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2016-08-11 15:14:51 | By :
                            funrun |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ลองแก้ตามนี้ดูครับ 
 Code
 
 $url = 'https://graph.facebook.com/oauth/access_token';
    $params = array(
    	"type" => "client_cred",
        "client_id" => 'xxxxx',
        "client_secret" => 'xxxxxxx',
"redirect_uri" => 'xxxxxx'
        );
 
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params, null, '&'));
    $ret = curl_exec($ch);
    curl_close($ch);
    var_dump($ret);
 
 ชุดนี้ผมลองเทสในเครื่องผมล่ะ ผ่านนะครับ
 
 |  
              | 
 ประวัติการแก้ไข
 2016-08-11 15:44:12
 2016-08-11 15:44:16
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2016-08-11 15:43:41 | By :
                            adaaugusta |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ผมลองทำตามแล้วมันยังได้ผลเป็น bool(false) 
 แต่ผมลองใช้คำสั่ง curl_error($ch) มันได้ผลเป็น couldn't connect to host
 
 อาการแบบนี้มันเป็นเพราะอะไรครับ
 
 |  
              | 
 ประวัติการแก้ไข
 2016-08-16 16:40:11
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2016-08-15 13:05:00 | By :
                            funrun |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | URL ห้ามขึ้นบรรทัดใหม่ ต้องเป็นบรรทัดเดียวกันเท่านั้น 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2016-08-17 14:40:58 | By :
                            goragod |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | อาการที่เจอมันไม่น่าจะเกี่ยวกับเรื่องนี้นะครับ 
 เพราะ URL ก็อยู่บรรทัดเดียวกันอยู่แล้ว ลอง view source ดูก็จะเห็น
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2016-08-18 12:51:00 | By :
                            funrun |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |