За последние 24 часа нас посетили 17612 программистов и 1723 робота. Сейчас ищут 945 программистов ...

cURL + header

Тема в разделе "PHP для новичков", создана пользователем joost, 21 фев 2008.

  1. joost

    joost Guest

    С помощю курл отправляю заголовки
    PHP:
    1.  
    2. $this_header = array(
    3. "Referer: [url=http://www.site.com/]http://www.site.com/[/url]",
    4. "Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
    5. );
    6.  
    7. curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
    8.  
    в результате в логах
    доступ делаю к page.php, но дает
    Agent - вообще пусто

    В чем причина?
     
  2. Anonymous

    Anonymous Guest

    Ключ => значение, емнип.
    типа, array('User-Agent'=>'MSIE 8.0; Windows; U');
     
  3. Anonymous

    Anonymous Guest

    А, да, заголовка Agent просто нет. В принципе. Есть User-agent
     
  4. joost

    joost Guest

    PHP:
    1.  
    2. $this_header = array(
    3. 'Referer' => 'http://www.site.com/',
    4. 'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'
    5. );
    6.  
    7. curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
    8.  
    так?

    тогда в логах "GET /page.php HTTP/1.0" 200 8274 "-" "-"

    полный листинг скрипта
    PHP:
    1.  
    2. function file_get_content($url,$str)
    3. {
    4. $ch = curl_init();
    5. curl_setopt($ch, CURLOPT_URL, $url);
    6.  
    7. $this_header = array(
    8.     'Referer' => 'http://www.site.com/',
    9.     'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'
    10. );
    11.  
    12. curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
    13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    14.  
    15. $str = curl_exec($ch);
    16.  
    17. return $str;
    18. }
    19. $str=file_get_content("http://site.net/page.php",$str);
    20.  
     
  5. Sergey89

    Sergey89 Активный пользователь

    С нами с:
    4 янв 2007
    Сообщения:
    4.796
    Симпатии:
    0
    А чего должно быть?
     
  6. joost

    joost Guest

    как минимум еще
     
  7. joost

    joost Guest

    или не должно быть?
     
  8. joost

    joost Guest

    так ка правильно сделать, чтобы в логах был Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ?
     
  9. joost

    joost Guest

    уже решил проблему!