WordPress.org

Support

Support » Plugins and Hacks » Flickr Shortcode Importer » [Resolved] [Plugin: Flickr Shortcode Importer] file_get_contents with url ISP does not support

[Resolved] [Plugin: Flickr Shortcode Importer] file_get_contents with url ISP does not support

  • Hi

    My isp does not allow file_get_contents to use urls, only local files. I replaced the call with a curl equivalent function (shown below). But then I got

    {“error”:””About” Post ID 24 failed to be processed. The error message was: Unknown failure reason.”}

    I’m using WordPress 3.3.2. PHP Version 5.2.17.

    I’ll try and figure out what is going on but using curl might be a good addition for the next update anyway.

    ~Toby

    function file_get_contents_curl($url) {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);

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

    return $data;
    }

    http://wordpress.org/extend/plugins/flickr-shortcode-importer/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The error was due to there being no titles on the files on flickr. prevent problem by checking $title has a value before using it.

    if ($title && fsi_get_options( ‘replace_file_name’ ) ) {

    also here is a more robust curl function

    function file_get_contents_curl($url) {
    $ch = curl_init();

    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);

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

    return $data;
    }

    Plugin Author Michael Cannon

    @comprock

    Great suggestion. Only problem will be when curl isn’t compiled into PHP.

    Anyways, I’ve put the code in for upcoming 1.7.8. We’ll see what happens.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] [Plugin: Flickr Shortcode Importer] file_get_contents with url ISP does not support’ is closed to new replies.
Skip to toolbar