Embedding tumblr feeds

ok, let's see if we can work this out!

I have some code that will allow me to pull images from a tumblr feed,select those images, and submit them.

I'd LOVE to add a tumblr button to the photo upload function in the wall.

Just kicking ideas around.  IDK if maybe it gets added to the member's profile, or it could get treated like a link.

<?php 
 
 
  if (isset($_POST['select'])){
    
    echo 'Selected photos!<br>';

      foreach ($_POST['PictureSelected'] as $sImage)
      echo '<img src="'.$sImage.'"><br>';
     
     
 }else if (isset($_POST['choose'])){
    getList($_POST['choose']);

}else{
     getForm();    
 }
    
 
 function getList(){
    
     $ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"http://{$_POST['choose']}.tumblr.com/api/read/json");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$result = curl_exec($ch);
curl_close($ch);

$result = str_replace("var tumblr_api_read = ","",$result);
$result = str_replace(';','',$result);
$result = str_replace('\u00a0','&amp;nbsp;',$result);

$jsondata = json_decode($result,true);
$posts = $jsondata['posts'];
echo '<form method="post" Name="Select">';

foreach($posts as $post){
    echo '<input type="checkbox" Name="PictureSelected[]" value="'.$post['photo-url-500'].'">';
   
    echo '<img src="'.$post['photo-url-500'].'" width="100px">';
}
echo '<br><input type="Submit" Name="select" value="select">';
echo '</form>';

 }

function getForm(){
   
    echo <<< EOF
    Enter name of Tumblr Group<br>
    <form method="post" action ="testtumblr.php">
    <input type="text" name="choose"><br>
    <input type="Submit" Name="Choose">
    </form>
   
EOF;

}

?>

Let's work together and see what we can come up with!

http://www.mytikibar.com
Quote · 3 May 2015

ok, I am still working on posting tumblr feeds to the wall.

To replicate this, here is post,html

 

<div class="wall-post" >   
    <div class="wall-loading" style="background-image:url(<bx_image_url:loading_bg.png />)"><img src="<bx_image_url:loading.gif />" /></div>
    <iframe class="wall_hidden" name="WallPostIframe"></iframe>
    <!-- Post Text -->
    <div class="wall-ptype-cnt wall_text">__post_wall_text__</div>
    <!-- Post Link -->
    <div class="wall-ptype-cnt wall_link">__post_wall_link__</div>
      <!-- Post Tumblr -->
    <div class="wall-ptype-cnt wall_tumblr">__post_wall_tumblr__</div>
    <!-- Post Photo -->
    <div class="wall-ptype-cnt wall_photo">__post_wall_photo__</div>
    <!-- Post Video -->
    <div class="wall-ptype-cnt wall_video">__post_wall_video__</div>
    <!-- Post Music -->
    <div class="wall-ptype-cnt wall_music">__post_wall_music__</div>   
    <script  type="text/javascript">
    <!--
        __post_js_content__
    -->
   
    </script>   
</div>
 <br style="height:1px;clear:both">

you have to edit this line in post.css

div.wall_tumblr,div.wall_text,div.wall_link,div.wall_photo,div.wall_video,div.wall_music{padding:0;margin:4px;display:none;border:0;float:left;width:98%}

 

bxWallModule.php

        $aTopMenu = array(           
            'wall-ptype-text' => array('href' => 'javascript:void(0)', 'onclick' => 'javascript:' . $this->_sJsPostObject . '.changePostType(this)', 'class' => 'wall-ptype-ctl', 'icon' => $this->_oTemplate->getIconUrl('post_text.png'), 'title' => _t('_wall_write'), 'active' => 1),
            'wall-ptype-link' => array('href' => 'javascript:void(0)', 'onclick' => 'javascript:' . $this->_sJsPostObject . '.changePostType(this)', 'class' => 'wall-ptype-ctl', 'icon' => $this->_oTemplate->getIconUrl('post_link.png'), 'title' => _t('_wall_share_link')),
            'wall-ptype-tumblr' => array('href' => 'javascript:void(0)', 'onclick' => 'javascript:' . $this->_sJsPostObject . '.changePostType(this)', 'class' => 'wall-ptype-ctl', 'icon' => $this->_oTemplate->getIconUrl('post_link.png'), 'title' => _t('_wall_share_tumblr'))

        );       

(I haven't changed the icon yet!)

        $aVariables = array (
            'post_js_content'  => $sJsContent,
            'post_js_object'   => $this->_sJsPostObject,
            'post_wall_text'   => $this->_getWriteForm(),
            'post_wall_link'   => $this->_getShareLinkForm(),
            'post_wall_tumblr' => $this->_getShareTumblrForm(),           
            'post_wall_photo' => '',
            'post_wall_video' => '',
            'post_wall_music' => '',
          
        );               

This shows up fine.

    function _getShareTumblrForm(){
       
         $aForm = array(
            'form_attrs' => array(
                'name' => 'WallPostTumblr',
                 'action' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'get_tumblr_feed/',
                'method' => 'post',
                'enctype' => 'multipart/form-data',
                'target' => 'WallPostIframe',
           ),
            'inputs' => array(
                'title' => array(
                    'type' => 'text',
                    'name' => 'feed',
                   'caption'  => _t('_wall_tumblr_feed'),
                ),
                'submit' => array(
                    'type' => 'submit',
                    'name' => 'submit',
                    'value' => _t('_tumblr_feed_select'),
                    'colspan' => true
                )
                ),          
            );
       $aForm['inputs'] = array_merge($aForm['inputs'], $this->_addHidden('tumblr'));
       
        $oForm = new BxTemplFormView($aForm);
        return $oForm->getCode();
    }

 

 

This is the part I am having trouble with.

The alert pops up if the $sFeed is empty.

AND if the tumblr feed is emtpy.

However, my next step is to display a form with radio buttons to select which image to post to the wall.

This will NOT post any output!

The form parameters are not done yet, I just want to see HTML in the box so I can go ahead and create the form to post the selected photo.

 

 

    function actionGetTumblrFeed(){               
        $sFeed = trim(process_db_input($_POST['feed'], BX_TAGS_STRIP));
        if(empty($sFeed)){
             $sResult = "alert('" . bx_js_string(_t('_wall_msg_tumblr_empty_feed')) . "');";
            return '<script>' . $sResult . '</script>';
            }
       
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"http://{$sFeed}.tumblr.com/api/read/json");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$result = curl_exec($ch);
curl_close($ch);

$result = str_replace("var tumblr_api_read = ","",$result);
$result = str_replace(';','',$result);
$result = str_replace('\u00a0','&amp;nbsp;',$result);

$jsondata = json_decode($result,true);

if ($jsondata['posts-total'] == 0){
     $sResult = "alert('" . bx_js_string(_t('No Posts Found!')) . "');";
            return '<script>' . $sResult . '</script>';
}



$posts = $jsondata['posts'];
$sReturn = '<form method="post" Name="Select">';

foreach($posts as $post){
    $sReturn .= '<input type="radio" Name="ImageSelected" value="'.$post['photo-url-500'].'">';
   
    $sReturn .= '<img src="'.$post['photo-url-500'].'" width="100px">';
}
$sReturn .= '<br><input type="Submit" Name="select" value="select">';
$sReturn .= '</form>';
                         
        return $sReturn;
       
    }

the $sReturn string DOES have the correct info in it.

So I am not sure HOW I get the next form to display so I can select POST to Wall.

Any help will be appreciated.


 

http://www.mytikibar.com
Quote · 6 May 2015
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.