function showGenNTSettings($ntOpts)
        {
            global $nxs_plurl, $nxs_snapSetPgURL, $nxs_gOptions;
            $ntInfo = $this->ntInfo;
            if (isset($_GET['auth']) && $_GET['auth'] == $ntInfo['lcode']) {
                require_once 'apis/scOAuth.php';
                $options = $ntOpts[$_GET['acc']];
                $consumer_key = $options['appKey'];
                $consumer_secret = $options['appSec'];
                $callback_url = $nxs_snapSetPgURL . "&auth=" . $ntInfo['lcode'] . "a&acc=" . $_GET['acc'];
                $tum_oauth = new wpScoopITOAuth($consumer_key, $consumer_secret);
                $tum_oauth->baseURL = 'https://www.flickr.com/services';
                $tum_oauth->request_token_path = '/oauth/request_token';
                $tum_oauth->access_token_path = '/oauth/access_token';
                $request_token = $tum_oauth->getReqToken($callback_url);
                $options['oAuthToken'] = $request_token['oauth_token'];
                $options['oAuthTokenSecret'] = $request_token['oauth_token_secret'];
                switch ($tum_oauth->http_code) {
                    case 200:
                        $url = 'https://www.flickr.com/services/oauth/authorize?oauth_token=' . $options['oAuthToken'];
                        if (function_exists('get_option')) {
                            $nxs_gOptions = get_option('NS_SNAutoPoster');
                        }
                        if (!empty($nxs_gOptions)) {
                            $nxs_gOptions[$ntInfo['lcode']][$_GET['acc']] = $options;
                            nxs_settings_save($nxs_gOptions);
                        }
                        echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "' . $url . '"</script>';
                        break;
                    default:
                        echo '<br/><b style="color:red">Could not connect to Flickr. Refresh the page or try again later.</b>';
                        die;
                }
                die;
            }
            if (isset($_GET['auth']) && $_GET['auth'] == $ntInfo['lcode'] . 'a') {
                require_once 'apis/scOAuth.php';
                $options = $ntOpts[$_GET['acc']];
                $consumer_key = $options['appKey'];
                $consumer_secret = $options['appSec'];
                $tum_oauth = new wpScoopITOAuth($consumer_key, $consumer_secret, $options['oAuthToken'], $options['oAuthTokenSecret']);
                //prr($tum_oauth);
                $tum_oauth->baseURL = 'https://www.flickr.com/services';
                $tum_oauth->request_token_path = '/oauth/request_token';
                $tum_oauth->access_token_path = '/oauth/access_token';
                $access_token = $tum_oauth->getAccToken($_GET['oauth_verifier']);
                prr($access_token);
                $options['accessToken'] = $access_token['oauth_token'];
                $options['accessTokenSec'] = $access_token['oauth_token_secret'];
                if (function_exists('get_option')) {
                    $nxs_gOptions = get_option('NS_SNAutoPoster');
                }
                if (!empty($nxs_gOptions)) {
                    $nxs_gOptions[$ntInfo['lcode']][$_GET['acc']] = $options;
                    nxs_settings_save($nxs_gOptions);
                }
                $tum_oauth = new wpScoopITOAuth($consumer_key, $consumer_secret, $options['accessToken'], $options['accessTokenSec']);
                echo "OK. Let's Get Profile: ";
                prr($access_token);
                $params = array('format' => 'php_serial', 'method' => 'flickr.urls.getUserProfile');
                $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/', $params);
                // prr($uinfo);die();
                if (is_array($uinfo) && isset($uinfo['user'])) {
                    $options['appAppUserName'] = $access_token['username'] . "(" . urldecode($access_token['fullname']) . ")";
                    $options['appAppUserID'] = urldecode($uinfo['user']['nsid']);
                    $options['userURL'] = urldecode($uinfo['user']['url']);
                    if (function_exists('get_option')) {
                        $nxs_gOptions = get_option('NS_SNAutoPoster');
                    }
                    if (!empty($nxs_gOptions)) {
                        $nxs_gOptions[$ntInfo['lcode']][$_GET['acc']] = $options;
                        nxs_settings_save($nxs_gOptions);
                    }
                }
                //die();
                if (!empty($options['appAppUserID'])) {
                    $gGet = $_GET;
                    unset($gGet['auth']);
                    unset($gGet['acc']);
                    unset($gGet['oauth_token']);
                    unset($gGet['oauth_verifier']);
                    unset($gGet['post_type']);
                    $sturl = explode('?', $nxs_snapSetPgURL);
                    $nxs_snapSetPgURL = $sturl[0] . (!empty($gGet) ? '?' . http_build_query($gGet) : '');
                    echo '<br/><br/>All good?! Redirecting ..... <script type="text/javascript">window.location = "' . $nxs_snapSetPgURL . '"</script>';
                    break;
                    die;
                } else {
                    die("<span style='color:red;'>ERROR: Authorization Error: <span style='color:darkred; font-weight: bold;'>" . print_r($uinfo, true) . "</span></span>");
                }
            }
            ?>
    <div class="nxs_box">
      <div class="nxs_box_header">
        <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php 
            echo $nxs_plurl;
            ?>
img/<?php 
            echo $ntInfo['lcode'];
            ?>
16.png);"><?php 
            echo $ntInfo['name'];
            ?>
          <?php 
            $cbo = count($ntOpts);
            ?>
          <?php 
            if ($cbo > 1) {
                ?>
<div class="nsBigText"><?php 
                echo "(" . ($cbo == '0' ? 'No' : $cbo) . " ";
                _e('accounts', 'nxs_snap');
                echo ")";
                ?>
</div><?php 
            }
            ?>
        </div>
      </div>
      <div class="nxs_box_inside">
        <?php 
            foreach ($ntOpts as $indx => $pbo) {
                if (trim($pbo['nName'] == '')) {
                    $pbo['nName'] = $ntInfo['name'];
                }
                if (!isset($pbo[$ntInfo['lcode'] . 'OK']) || $pbo[$ntInfo['lcode'] . 'OK'] == '') {
                    $pbo[$ntInfo['lcode'] . 'OK'] = isset($pbo['appAppUserID']) && $pbo['appAppUserID'] > 1 ? '1' : '';
                }
                ?>
            <p style="margin:0px;margin-left:5px;"> <img id="<?php 
                echo $ntInfo['code'] . $indx;
                ?>
LoadingImg" style="display: none;" src='<?php 
                echo $nxs_plurl;
                ?>
img/ajax-loader-sm.gif' />

            <?php 
                if ((int) $pbo['do' . $ntInfo['code']] == 1 && isset($pbo['catSel']) && (int) $pbo['catSel'] == 1) {
                    ?>
 <input type="radio" name="<?php 
                    echo $ntInfo['lcode'];
                    ?>
[<?php 
                    echo $indx;
                    ?>
][apDo<?php 
                    echo $ntInfo['code'];
                    ?>
]" id="rbtn<?php 
                    echo $ntInfo['lcode'] . $indx;
                    ?>
" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php 
                } else {
                    ?>
            <input value="0" name="<?php 
                    echo $ntInfo['lcode'];
                    ?>
[<?php 
                    echo $indx;
                    ?>
][apDo<?php 
                    echo $ntInfo['code'];
                    ?>
]" type="hidden" />
            <input value="1" name="<?php 
                    echo $ntInfo['lcode'];
                    ?>
[<?php 
                    echo $indx;
                    ?>
][apDo<?php 
                    echo $ntInfo['code'];
                    ?>
]" type="checkbox" <?php 
                    if ((int) $pbo['do' . $ntInfo['code']] == 1 && $pbo['catSel'] != '1') {
                        echo "checked";
                    }
                    ?>
 />
            <?php 
                }
                ?>
            <?php 
                if (isset($pbo['catSel']) && (int) $pbo['catSel'] == 1) {
                    ?>
 <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php 
                    echo "*[" . (substr_count($pbo['catSelEd'], ",") + 1) . "]*";
                    ?>
</span><?php 
                }
                ?>
            <?php 
                if (isset($pbo['rpstOn']) && (int) $pbo['rpstOn'] == 1) {
                    ?>
 <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php 
                    echo "*[R]*";
                    ?>
</span><?php 
                }
                ?>
            <strong><?php 
                _e('Auto-publish to', 'nxs_snap');
                ?>
 <?php 
                echo $ntInfo['name'];
                ?>
 <i style="color: #005800;"><?php 
                if ($pbo['nName'] != '') {
                    echo "(" . $pbo['nName'] . ")";
                }
                ?>
</i></strong>
          &nbsp;&nbsp;<?php 
                if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'] . 'OK']) || $pbo[$ntInfo['lcode'] . 'OK'] == '')) {
                    ?>
<b style="color: #800000"><?php 
                    _e('Attention requred. Unfinished setup', 'nxs_snap');
                    ?>
 ==&gt;</b><?php 
                }
                ?>
          <a id="do<?php 
                echo $ntInfo['code'] . $indx;
                ?>
AG" href="#" onclick="doGetHideNTBlock('<?php 
                echo $ntInfo['code'];
                ?>
' , '<?php 
                echo $indx;
                ?>
');return false;">[<?php 
                _e('Show Settings', 'nxs_snap');
                ?>
]</a>&nbsp;&nbsp;
          <a href="#" onclick="doDelAcct('<?php 
                echo $ntInfo['lcode'];
                ?>
', '<?php 
                echo $indx;
                ?>
', '<?php 
                if (isset($pbo['bgBlogID'])) {
                    echo $pbo['nName'];
                }
                ?>
');return false;">[<?php 
                _e('Remove Account', 'nxs_snap');
                ?>
]</a>
          </p><div id="nxsNTSetDiv<?php 
                echo $ntInfo['code'] . $indx;
                ?>
"></div><?php 
                //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);
            }
            ?>
      </div>
    </div> <?php 
        }
Esempio n. 2
0
 function doPostToNT($options, $message)
 {
     global $nxs_urlLen;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['accessToken']) || trim($options['accessToken']) == '') {
         $badOut['Error'] = 'Not Authorized';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format Post
     if (!empty($message['pText'])) {
         $text = $message['pText'];
     } else {
         $text = nxs_doFormatMsg($options['msgFrmt'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message);
     }
     //## Make Post
     if (isset($message['imageURL'])) {
         $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $imgURL = '';
     }
     $postType = $options['postType'];
     if (empty($imgURL)) {
         $badOut['Error'] = 'No Image. Flickr is an image-sharing network. You can\'t post to Flickr without image.';
         return $badOut;
     }
     require_once 'apis/scOAuth.php';
     $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']);
     $tum_oauth->baseURL = 'https://www.flickr.com/services';
     $tum_oauth->request_token_path = '/oauth/request_token';
     $tum_oauth->access_token_path = '/oauth/access_token';
     $tags = $message['tags'];
     $postArr = array('title' => $msgT, 'description' => $text, 'tags' => $tags, 'is_public' => 1, 'safety_level' => 1, 'content_type' => 1, 'hidden' => 1);
     $imgFile = $this->createFile($imgURL);
     if (empty($imgFile) || is_array($imgFile)) {
         $badOut['Error'] = 'Image Error - ' . print_r($imgFile, true);
         return $badOut;
     }
     $phiID = $tum_oauth->flUploadPhoto($imgFile, $postArr);
     // prr($phiID);
     if (!empty($phiID) && strpos($phiID, 'Problem: ') === false) {
         $params = array('format' => 'php_serial', 'method' => 'flickr.photosets.addPhoto', 'photo_id' => $phiID, 'photoset_id' => $options['setID']);
         $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/', $params);
         if (!empty($message['latitude']) && !empty($message['longitude'])) {
             $params = array('format' => 'php_serial', 'method' => 'flickr.photos.geo.setLocation', 'photo_id' => $phiID, 'lat' => $message['latitude'], 'lon' => $message['longitude']);
             $uinfo = $tum_oauth->makeReq('https://api.flickr.com/services/rest/', $params);
         }
     }
     if (!empty($phiID) && strpos($phiID, 'Problem: ') === false) {
         return array('postID' => $phiID, 'isPosted' => 1, 'postURL' => str_ireplace('people', 'photos', $options['userURL']) . $phiID, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($phiID, true) . " Code:" . $tum_oauth->http_code;
         return $badOut;
     }
     return $badOut;
 }
Esempio n. 3
0
 function doPostToNT($options, $message)
 {
     global $nxs_urlLen;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['accessToken']) || trim($options['accessToken']) == '') {
         $badOut['Error'] = 'Not Authorized';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format Post
     if (!empty($message['pText'])) {
         $msg = $message['pText'];
     } else {
         $msg = nxs_doFormatMsg($options['msgFrmt'], $message);
     }
     //## Make Post
     if (isset($message['imageURL'])) {
         $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $imgURL = '';
     }
     $postType = $options['postType'];
     require_once 'apis/scOAuth.php';
     $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']);
     $tum_oauth->baseURL = 'https://api.xing.com';
     $msg = str_replace('&amp;#039;', "'", $msg);
     $msg = str_replace('&#039;', "'", $msg);
     $msg = str_replace('#039;', "'", $msg);
     $msg = str_replace('#039', "'", $msg);
     $msg = str_replace('&amp;#8217;', "'", $msg);
     $msg = str_replace('&#8217;', "'", $msg);
     $msg = str_replace('#8217;', "'", $msg);
     $msg = str_replace('#8217', "'", $msg);
     $msg = str_replace('&amp;#8220;', '"', $msg);
     $msg = str_replace('&#8220;', '"', $msg);
     $msg = str_replace('#8220;', '"', $msg);
     $msg = str_replace('#8220', "'", $msg);
     $msg = str_replace('&amp;#8221;', '"', $msg);
     $msg = str_replace('&#8221;', '"', $msg);
     $msg = str_replace('#8221;', '"', $msg);
     $msg = str_replace('#8221', "'", $msg);
     $msg = str_replace('&amp;#8212;', '-', $msg);
     $msg = str_replace('&#8212;', '-', $msg);
     $msg = str_replace('#8212;', '-', $msg);
     $msg = str_replace('#8212', "-", $msg);
     if ($postType == 'A') {
         $postArr = array('uri' => urlencode($message['url']), 'text' => nsTrnc($msg, 420));
         $postinfo = $tum_oauth->makeReq('https://api.xing.com/v1/users/me/share/link', $postArr, 'POST');
     } else {
         $postArr = array('message' => nsTrnc($msg, 420), 'id' => $options['appAppUserID']);
         $postinfo = $tum_oauth->makeReq('https://api.xing.com/v1/users/' . $options['appAppUserID'] . '/status_message', $postArr, 'POST');
         // prr($postinfo);
     }
     $code = $tum_oauth->http_code;
     if ($code == '201') {
         if (!empty($postinfo) && is_array($postinfo) && !empty($postinfo['ids']) && !empty($postinfo['ids'][0])) {
             $apNewPostID = $postinfo['ids'][0];
         }
         $np = explode('_', $apNewPostID);
         $apNewPostURL = 'https://www.xing.com/feedy/stories/' . $np[0];
     } else {
         $apNewPostID = '';
         $apNewPostURL = 'https://www.xing.com/profile/' . $options['appPGUserName'] . '/activities';
     }
     if (!empty($apNewPostID) || $code == '201') {
         return array('postID' => $apNewPostID, 'isPosted' => 1, 'postURL' => $apNewPostURL, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($postinfo, true) . " Code:" . $tum_oauth->http_code;
         return $badOut;
     }
     return $badOut;
 }
Esempio n. 4
0
 function doPostToNT($options, $message)
 {
     global $nxs_urlLen;
     $badOut = array('pgID' => '', 'isPosted' => 0, 'pDate' => date('Y-m-d H:i:s'), 'Error' => '');
     //## Check settings
     if (!is_array($options)) {
         $badOut['Error'] = 'No Options';
         return $badOut;
     }
     if (!isset($options['accessToken']) || trim($options['accessToken']) == '') {
         $badOut['Error'] = 'Not Authorized';
         return $badOut;
     }
     if (empty($options['imgSize'])) {
         $options['imgSize'] = '';
     }
     //## Format Post
     if (!empty($message['pText'])) {
         $text = $message['pText'];
     } else {
         $text = nxs_doFormatMsg($options['msgFrmt'], $message);
     }
     if (!empty($message['pTitle'])) {
         $msgT = $message['pTitle'];
     } else {
         $msgT = nxs_doFormatMsg($options['msgTFrmt'], $message);
     }
     //## Make Post
     if (isset($message['imageURL'])) {
         $imgURL = trim(nxs_getImgfrOpt($message['imageURL'], $options['imgSize']));
     } else {
         $imgURL = '';
     }
     $postType = $options['postType'];
     require_once 'apis/scOAuth.php';
     $tum_oauth = new wpScoopITOAuth($options['appKey'], $options['appSec'], $options['accessToken'], $options['accessTokenSec']);
     $tiID = $tum_oauth->makeReq('http://www.scoop.it/api/1/topic', array('urlName' => $options['topicURL']));
     if (!empty($tiID) && is_array($tiID) && !empty($tiID['topic']) && !empty($tiID['topic']['id'])) {
         $tiID = $tiID['topic']['id'];
     } else {
         $badOut['Error'] .= print_r($tiID, true);
         return $badOut;
     }
     $postArr = array('action' => 'create', 'title' => $msgT, 'content' => $text, 'url' => $postType == 'A' ? $message['url'] : '', 'imageUrl' => ($postType == 'I' || $postType == 'A') && !empty($imgURL) ? $imgURL : '', 'topicId' => $tiID);
     $postinfo = $tum_oauth->makeReq('http://www.scoop.it/api/1/post', $postArr, 'POST');
     // prr($postinfo);
     if (is_array($postinfo) && isset($postinfo['post'])) {
         $apNewPostID = $postinfo['post']['id'];
         $apNewPostURL = $postinfo['post']['scoopUrl'];
         if ($options['inclTags'] == '1') {
             $postArr = array('action' => 'edit', 'tag' => $message['tags'], 'id' => $apNewPostID);
             $postinfo = $tum_oauth->makeReq('http://www.scoop.it/api/1/post', $postArr, 'POST');
         }
     }
     $code = $tum_oauth->http_code;
     if (!empty($apNewPostID)) {
         return array('postID' => $apNewPostID, 'isPosted' => 1, 'postURL' => $apNewPostURL, 'pDate' => date('Y-m-d H:i:s'));
     } else {
         $badOut['Error'] .= print_r($postinfo, true) . " Code:" . $tum_oauth->http_code;
         return $badOut;
     }
     return $badOut;
 }