Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter vitious

    (@vitious)

    Hi there, about the auto post test you asked. I tried to reload and waited for post creation but nothing happens. I tried also visiting from different browsers and ips, but nothing. No clues as to what to do now.
    Can you tell me how to see the php logs?

    Thread Starter vitious

    (@vitious)

    Yes, now all pictures with selected tag are showing in the stream of the second tab. Thanks for the quick update. I’ve set auto posting in the settings to see if everything works as expected, I’ll let you know next time I’ll take a picture.

    Thread Starter vitious

    (@vitious)

    Great, keep us posted! Sorry if my code created problems, and thanks for fixing the query.

    Thread Starter vitious

    (@vitious)

    That’s great news, looking forward to it. Thanks.

    Thread Starter vitious

    (@vitious)

    Yes, checkbox is the way in my opinion, a third tab would be confusing.
    First tab: user stream with a checkbox for user-only photos.
    Second tab: chosen tag stream with a checkbox for user-only photos.

    OT:
    If you’re in the process of releasing a new version, consider also this
    feature: I’ve added to your wpinstaroll_createpostfromphoto function, in the $post_args array, ‘tags_input’ => ‘add_this_tag’. Adds a custom tag to the post. It could be taken from a box in the settings but I haven’t modified the settings since I’ll be only using one tag.

    As always, thanks.

    Thread Starter vitious

    (@vitious)

    Here it is, the second API. Now in the second tab there are only pictures by current user with the panel-choosen tag.

    // gets Instagram pics corresponding to passed hashtag
    // testing a filter by userid
    
    function wpinstaroll_getInstagramPhotosWithTag($tag)
    {
    	if (empty($tag))
    		return null;
    
    	$accessToken = get_option(WP_ROLL_INSTAGRAM_PLUGIN_PREFIX.'_instagram_user_accesstoken');
    
    	if (empty($accessToken))
    		return null;
    
    	// API: http://instagr.am/developer/endpoints/tags/
    	//$file_contents = file_get_contents(WP_ROLL_INSTAGRAM_STREAM_BYTAG_URL_A.$tag.WP_ROLL_INSTAGRAM_STREAM_BYTAG_URL_B.$accessToken);
    	$file_contents = @curl_file_get_contents(WP_ROLL_INSTAGRAM_STREAM_BYTAG_URL_A.$tag.WP_ROLL_INSTAGRAM_STREAM_BYTAG_URL_B.$accessToken);
    
    	if (empty($file_contents))
    		return null;
    
    	$photo_data = json_decode($file_contents);
    
    	// declare a function that checks against userid
    	function test_id($test_var)
    	{
    		$id = $test_var->user->id;
    		if ($id === get_option(WP_ROLL_INSTAGRAM_PLUGIN_PREFIX.'_instagram_user_userid'))
    			return true;
    		else
    			return false;
    	}
    
    	// filter the data array with the test function
    	$photo_data_array = $photo_data->data;
    	$photo_data->data = array_filter($photo_data_array, "test_id");
    
    	// proceed as before with the filtered $photo_data
    	// add photo data (if new) to local db
    	wpinstaroll_updateLocalDBWithNewPhotos($photo_data);
    
    	return $photo_data;
    
    }

    Thread Starter vitious

    (@vitious)

    Hi there,
    I was considering the same approaches. For testing purposes I modified the first API (userStream), the code below filters correctly for the passed tag (#exampleofpassedtag). Now I’m restoring the API to it’s original status and working on modifying the second (PhotosWithTag), because I think the right way to do it is panel->choose tag and let the API assume by default you are the user to filter by. I’ll let you know. Meanwhile, thanks again for your work and, of course, any suggestion or correction is more than welcome.

    // *** INSTAGRAM API ***
    
    // gets Instagram stream for current logged user (contains pics sent only by the user*)
    
    function wpinstaroll_getInstagramUserStream()
    {
    	$accessToken = get_option(WP_ROLL_INSTAGRAM_PLUGIN_PREFIX.'_instagram_user_accesstoken');
    
    	if (empty($accessToken))
    		return null;
    
    	// API: http://instagr.am/developer/endpoints/users/
    	//$file_contents = @file_get_contents(WP_ROLL_INSTAGRAM_USER_STREAM_URLBASE.$accessToken);
    
    	// old code contained pictures sent both by users and his friends
    	//$file_contents = @curl_file_get_contents(WP_ROLL_INSTAGRAM_USER_STREAM_URLBASE.$accessToken);
    
    	// *modified: retrieves only photos by instagram userid fetched from db stored during authorization
    	// see: http://wordpress.org/support/topic/plugin-wp-instaroll-you-need-to-configure-message-persists
    
    	$instagram_user_id = get_option(WP_ROLL_INSTAGRAM_PLUGIN_PREFIX.'_instagram_user_userid');
    	$file_contents = @curl_file_get_contents('https://api.instagram.com/v1/users/'.$instagram_user_id.'/media/recent/?access_token='.$accessToken);
    
    	if (empty($file_contents))
    		return null;
    
    	// first of all decode the stream
    	$photo_data = json_decode($file_contents);
    
    	// declare a function that searches for a a tag and, if present, returns true
    	function test_tags($test_me)
    	{
    		$tag_array = $test_me->tags;
    		foreach ($tag_array as $tag_check)
    		{
    			if ($tag_check==="exampleofpassedtag")
    				return true;
    			else
    				return false;
    		}
    	}
    
    	// filter the data array with the test function
    	$photo_data_array = $photo_data->data;
    	$photo_data->data = array_filter($photo_data_array, "test_tags");
    
    	// proceed as before with the filtered $photo_data
    
    	// add photo data (if new) to local db
    	wpinstaroll_updateLocalDBWithNewPhotos($photo_data);
    
    	return $photo_data;
    
    }
    Thread Starter vitious

    (@vitious)

    Just a quick update.
    I’m working on a filter for the output of the json_decode inside wpinstaroll_getInstagramUserStream that only displays results if a tag criteria is matched (reading $photo_data->data->tags). So far no luck.
    Am I going in the right direction or is this approach wrong?
    Forgive me, I’m just learning this.
    Thanks again

    Thread Starter vitious

    (@vitious)

    Thank you for the quick reply.
    I’ve tried that code modifiactions, they’re working fine and now I’m wondering if there’s a way in the meanwhile to modify that call in order to include also a tag endpoint? That would be a temporary solution obviously, I haven’t dug into the api that much.

Viewing 9 replies - 1 through 9 (of 9 total)