2017-08-02 41 views
0

當我們拿到twits時,我們如何從twitter獲取Twitter卡片數據。 我的代碼是如何從twitter獲取twitter卡片數據表格

libxml_use_internal_errors(true); 
       $page_html = new DomDocument(); 

       $ch = curl_init(); 

       $timeout = 500; 

       curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); 
       curl_setopt($ch, CURLOPT_HEADER, 0); 
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
       curl_setopt($ch, CURLOPT_URL, $url); 
       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); 
       curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 3);  
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
       curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 

       $data = curl_exec($ch); 
       curl_close($ch); 

      if(!empty($data)){ 

       $page_html->loadHTML($data); 

      } 
+0

我不明白這個問題 - 你的代碼中沒有提及推特,所以你能解釋一下你想做的更清楚嗎? –

+0

我可以從Twitter API獲取Twitter卡嗎http://prntscr.com/gb2myt –

+0

沒有卡數據在API中不可用,並且由Twitter本機客戶端應用程序呈現在服務器端。 –

回答

0

從API獲取Twitter卡數據是不可能的。