Forum Replies Created

Viewing 1 replies (of 1 total)
  • In response to rmckillen’s post re: bit.ly and servers not allowing file_get_contents() I have spent the last few hours coming up with this to get around that.

    Replace
    $url = apply_filters('tweet_blog_post_url', get_permalink($post_id));

    with

    $ch = curl_init("https://api.bit.ly/shorten?format=xml;version=2.0.1&login=USERNAME&apiKey=APIKEY&longUrl=".get_permalink($post_id));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $data = curl_exec($ch);
    curl_close($ch);
    $xml = new SimpleXmlElement($data, LIBXML_NOCDATA);
    $bitly = $xml->results->nodeKeyVal->shortUrl;
    $url = apply_filters('tweet_blog_post_url', $bitly);

    Hope that helps anyone that needs it.

Viewing 1 replies (of 1 total)