Problem with PHP function file_get_contents

  • Hello,


    I'm trying to get infomation from https://vines.co with a script like this


    PHP
    1. <?php$opts = array('http' => array( 'header' => 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; es-CL; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3' . PHP_EOL ));$context = stream_context_create($opts);$str = file_get_contents('https://vine.co/v/heHa2lIwjVH',false,$context);echo $str; if(strlen($str)>0){ preg_match('/\<meta name="keywords" content="(.*)\">/',$str,$title); echo $title[1]; }phpinfo();?>


    But don't find the why to works ! I test this same script on another web server and works, but when I test on IMSCP webserver doesn't.


    I changed this next config :


    allow_url_fopen = On


    But allways got this error :


    Code
    1. Warning: file_get_contents(https://vine.co/v/heHa2lIwjVH): failed to open stream: HTTP request failed! HTTP/1.1 500 Server Error in /var/www/virtual/xxxxxxx.net/htdocs/test.php on line 8


    Any idea what I'm doing wrong ? Any config to change ?


    Thanks
    Martin

  • I have test your script, i don't have this error on i-MSCP.


    Verify in your php.ini :


    extension=php_openssl.dll
    allow_url_fopen = On


    Or try this script for test :


    $w = stream_get_wrappers();
    echo 'openssl: ', extension_loaded ('openssl') ? 'yes':'no', "\n";
    echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "\n";
    echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "\n";
    echo 'wrappers: ', var_dump($w);

    Debian 6 with proxmox 2 - OpenVZ - KVM
    I-mscp 1.0.3.0 migrate from ispcp 1.0.7
    dovecot + zarafa + z-push + maia mail guard + apacheITK

    Edited once, last by krok ().



  • I should probably kill you :P


    Code
    1. extension=php_openssl.dll


    Since when i-MSCP is running on windaub :angel:

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

    Edited once, last by Nuxwin ().

  • R I P


    sorry my mistakes, so confuse to work on both environnement.
    openssl is compil.

    Debian 6 with proxmox 2 - OpenVZ - KVM
    I-mscp 1.0.3.0 migrate from ispcp 1.0.7
    dovecot + zarafa + z-push + maia mail guard + apacheITK


  • Hello Krok,


    I try with the script and got this output :


    openssl: yes
    http wrapper: yes
    https wrapper: yes
    wrappers: array(12) { [0]=> string(5) "https" [1]=> string(4) "ftps" [2]=> string(13) "compress.zlib" [3]=> string(14) "compress.bzip2" [4]=> string(3) "php" [5]=> string(4) "file" [6]=> string(4) "glob" [7]=> string(4) "data" [8]=> string(4) "http" [9]=> string(3) "ftp" [10]=> string(4) "phar" [11]=> string(3) "zip" }


    Any idea ?
    [hr]


    Take a look in your test.php
    There should be the problem


    Hello TheCry,


    could be a little more specific ?


    Thank you for your replay.


    Martin

    Edited once, last by @maceto ().

  • Run the test.php script direct over http... Have a look in you error.log... The error 500 will come from the test.php

  • I think is not a php syntax error,


    the 500 error is returned by the server "https://vine.co/v/heHa2lIwjVH"
    your script work on my server i-mSCP 1.0.3

    Debian 6 with proxmox 2 - OpenVZ - KVM
    I-mscp 1.0.3.0 migrate from ispcp 1.0.7
    dovecot + zarafa + z-push + maia mail guard + apacheITK