Forums

CURL fetched content pushing previous content down [repost] (1 post)

  1. kencook
    Member
    Posted 1 year ago #

    (Reposted from Plugins and Hacks)

    I have written a plugin using CURL to fetch HTML from a file and publish it to a page/post or widget using a shortcode. I also have a Facebook "like" button and the Twitter button installed and activated with settings to publish before (at the top) of posts and pages.

    See http://thekencook.com/remotified

    When I use the shortcode the content publishes before the Twitter/Facebook pushing them to the bottom of the page just above the comments section. If I use the shortcode in a widget the TITLE publishes beneath the content in the sidebar instead of on top of it. Ideas?

    function get_data($url)
    {
    	$curl_handle=curl_init();
    	curl_setopt($curl_handle,CURLOPT_URL,'sometext.txt');
    	curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
    	curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
    	$buffer = curl_exec($curl_handle);
    	curl_close($curl_handle);
    
    		if (empty($buffer))
    	{
    		print "New data is unavailable but coming soon!<p>";
    	}
    	else
    	{
    		print ("<p>$buffer</p>");
    	}
    }
    
    add_shortcode('content-ddk', 'get_data');

Topic Closed

This topic has been closed to new replies.

About this Topic