コード例 #1
0
ファイル: kt.php プロジェクト: digideskio/stammtisch
 function showGenNTSettings($ntOpts)
 {
     global $nxs_plurl, $nxs_snapSetPgURL;
     $ntInfo = $this->ntInfo;
     $ntParams = array('ntInfo' => $ntInfo, 'nxs_plurl' => $nxs_plurl, 'ntOpts' => $ntOpts, 'chkField' => 'uPass');
     nxs_showListRow($ntParams);
 }
コード例 #2
0
 function showGenNTSettings($ntOpts)
 {
     global $nxs_plurl;
     $ntInfo = array('code' => 'TW', 'lcode' => 'tw', 'name' => 'Twitter', 'defNName' => 'dlUName', 'tstReq' => true);
     $ntParams = array('ntInfo' => $ntInfo, 'nxs_plurl' => $nxs_plurl, 'ntOpts' => $ntOpts, 'chkField' => 'twAccTokenSec');
     nxs_showListRow($ntParams);
 }
コード例 #3
0
 function showGenNTSettings($ntOpts)
 {
     global $nxs_plurl;
     $ntInfo = array('code' => 'GP', 'lcode' => 'gp', 'name' => 'Google+', 'defNName' => 'gpUName', 'tstReq' => false);
     $fMsg = 'Google+ doesn\'t have a built-in API for automated posts yet. The current <a href="http://developers.google.com/+/api/">Google+ API</a> is "Read Only" and can\'t be used for posting.  <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/google-plus-automated-posting">library module</a> to be able to publish your content to Google+.';
     $ntParams = array('ntInfo' => $ntInfo, 'nxs_plurl' => $nxs_plurl, 'ntOpts' => $ntOpts, 'chkField' => '', 'checkFunc' => array('funcName' => 'doPostToGooglePlus', 'msg' => $fMsg));
     nxs_showListRow($ntParams);
 }
コード例 #4
0
ファイル: st.php プロジェクト: brettex/pspark
 function showGenNTSettings($ntOpts)
 {
     global $nxs_plurl, $nxs_snapSetPgURL;
     $ntInfo = $this->ntInfo;
     $fMsg = 'SETT doesn\'t have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/api/thoughts-automated-posting/">API library</a> to be able to publish your content to SETT.';
     $ntParams = array('ntInfo' => $ntInfo, 'nxs_plurl' => $nxs_plurl, 'ntOpts' => $ntOpts, 'chkField' => 'appAppUserID', 'checkFunc' => array('funcName' => 'doPostToSETT', 'msg' => $fMsg));
     nxs_showListRow($ntParams);
 }
コード例 #5
0
ファイル: pn.php プロジェクト: voquanghoa/WebPhim
      function showGenNTSettings($ntOpts)
      {
          global $nxs_plurl;
          $ntInfo = $this->ntInfo;
          $fMsg = 'Pinterest doesn\'t have a built-in API for automated posts yet. <br/>You need to get a special <a target="_blank" href="http://www.nextscripts.com/pinterest-automated-posting">library module</a> to be able to publish your content to Pinterest.';
          $ntParams = array('ntInfo' => $ntInfo, 'nxs_plurl' => $nxs_plurl, 'ntOpts' => $ntOpts, 'chkField' => 'apPNUName', 'checkFunc' => array('funcName' => 'doPostToPinterest', 'msg' => $fMsg));
          nxs_showListRow($ntParams);
          ?>
  
 <?php 
      }
コード例 #6
0
ファイル: fb.php プロジェクト: voquanghoa/WebPhim
        function showGenNTSettings($ntOpts)
        {
            global $nxs_snapSetPgURL, $nxs_plurl;
            $ntInfo = array('code' => 'FB', 'lcode' => 'fb', 'name' => 'Facebook', 'defNName' => 'dlUName', 'tstReq' => true);
            if (isset($_GET['code']) && $_GET['code'] != '' && isset($_GET['state']) && substr($_GET['state'], 0, 7) == 'nxs-fb-') {
                $at = $_GET['code'];
                $ii = str_replace('nxs-fb-', '', $_GET['state']);
                echo "-= This is normal technical authorization info that will dissapear (Unless you get some errors) =- <br/><br/><br/>";
                $gGet = array();
                if (!empty($_SERVER['QUERY_STRING'])) {
                    parse_str($_SERVER['QUERY_STRING'], $gGet);
                } elseif (!empty($_SERVER['argv'][0])) {
                    parse_str($_SERVER['argv'][0], $gGet);
                } else {
                    $gGet = $_GET;
                    prr($_GET);
                    unset($gGet['post_type']);
                }
                prr($gGet);
                unset($gGet['code']);
                unset($gGet['state']);
                prr($gGet);
                $sturl = explode('?', $nxs_snapSetPgURL);
                $nxs_snapSetPgURL = $sturl[0] . (!empty($gGet) ? '?' . http_build_query($gGet) : '');
                $fbo = $ntOpts[$ii];
                $wprg = array();
                $response = wp_remote_get('https://graph.facebook.com/nextscripts', $wprg);
                if (is_wp_error($response) && isset($response->errors['http_request_failed']) && stripos($response->errors['http_request_failed'][0], 'SSL') !== false) {
                    prr($response->errors);
                    $wprg['sslverify'] = false;
                }
                if (isset($fbo['fbPgID'])) {
                    echo "-=";
                    prr($fbo);
                    // die();
                    $tknURL = 'https://graph.facebook.com/oauth/access_token?client_id=' . $fbo['fbAppID'] . '&state=nxs-fb-' . $ii . '&redirect_uri=' . urlencode($nxs_snapSetPgURL) . '&client_secret=' . $fbo['fbAppSec'] . '&code=' . $at;
                    $response = wp_remote_get($tknURL, $wprg);
                    prr($tknURL);
                    if (is_object($response) && isset($response->errors) || is_array($response) && stripos($response['body'], '"error":') !== false) {
                        prr($response);
                        die;
                    }
                    parse_str($response['body'], $params);
                    $at = $params['access_token'];
                    prr($response);
                    prr($params);
                    $response = wp_remote_get('https://graph.facebook.com/oauth/access_token?client_secret=' . $fbo['fbAppSec'] . '&client_id=' . $fbo['fbAppID'] . '&grant_type=fb_exchange_token&fb_exchange_token=' . $at, $wprg);
                    if (is_object($response) && isset($response->errors)) {
                        prr($response);
                        die;
                    }
                    parse_str($response['body'], $params);
                    $at = $params['access_token'];
                    $fbo['fbAppAuthToken'] = $at;
                    $appsecret_proof = hash_hmac('sha256', $fbo['fbAppAuthToken'], $fbo['fbAppSec']);
                    $aacct = array('access_token' => $fbo['fbAppAuthToken'], 'appsecret_proof' => $appsecret_proof, 'method' => 'get');
                    $res = wp_remote_get("https://graph.facebook.com/me?" . http_build_query($aacct, null, '&'));
                    if (is_wp_error($res) || empty($res['body'])) {
                        echo "Can't get Facebook User.";
                        prr($res);
                        die;
                    } else {
                        $user = json_decode($res['body'], true);
                        if (empty($user)) {
                            echo "Can't get Facebook User. JSON Error. ";
                            prr($res);
                            die;
                        } else {
                            if (!empty($user['id'])) {
                                echo "-= Got user: "******"-= Authorizing Page =-";
                                if (!is_numeric($page_id) && stripos($fbo['fbURL'], '/groups/') != false) {
                                    //$fbPgIDR = wp_remote_get('nxs.php?g='.$fbo['fbURL']); // TODO - how to replace
                                    $fbPgIDR = trim($fbPgIDR['body']);
                                    $page_id = $fbPgIDR != '' ? $fbPgIDR : $page_id;
                                }
                                $aacct = array('access_token' => $fbo['fbAppAuthToken'], 'appsecret_proof' => $appsecret_proof, 'method' => 'get');
                                $fbo['destType'] = '';
                                echo "https://graph.facebook.com/{$page_id}?fields=access_token&" . http_build_query($aacct, null, '&');
                                $res = wp_remote_get("https://graph.facebook.com/{$page_id}?fields=access_token&" . http_build_query($aacct, null, '&'));
                                prr($res);
                                if (is_wp_error($res) || empty($res['body'])) {
                                    echo "Can't get Page Token.";
                                    prr($res);
                                    die;
                                } else {
                                    $token = json_decode($res['body'], true);
                                    if (empty($token)) {
                                        echo "Can't get Page Token. JSON Error. ";
                                        prr($res);
                                        die;
                                    } else {
                                        if (!empty($token['error'])) {
                                            if (!empty($token['error']['message'])) {
                                                $errMsg = $token['error']['message'];
                                                if (stripos($errMsg, 'Unknown fields: access_token') !== false || stripos($errMsg, 'Cannot query users by their username') !== false || stripos($errMsg, 'node type (User)') !== false) {
                                                    $token['access_token'] = $fbo['fbAppAuthToken'];
                                                    $fbo['destType'] = stripos($fbo['fbURL'], '/groups/') != false ? 'gr' : 'pr';
                                                } else {
                                                    if (stripos($errMsg, 'Unsupported get request') !== false) {
                                                        echo "<b style='color:red;'>Error </b>: Your Facebook URL ( <i>" . $fbo['fbURL'] . "</i> ) is either incorrect or authorzing user don't have rights to post there.<br/>";
                                                    }
                                                    echo '<br/>Reported Error: ', $errMsg, "\n";
                                                    die;
                                                }
                                            }
                                        }
                                        if (!empty($token['access_token'])) {
                                            $fbo['fbAppPageAuthToken'] = $token['access_token'];
                                        } else {
                                            echo "Can't get Page Token. NO TOKEN RETURNED. Are you sure that user you are trying to authorize is an admin of the page? This message means user was authorized as profile, but page refused to return authorization token. This usually happens when user has <b>no rights</b> to post to that page. ";
                                            prr($res);
                                            die;
                                        }
                                    }
                                }
                            } else {
                                echo "Can't get User. NO USER RETURNED. ";
                                prr($res);
                                die;
                            }
                        }
                    }
                    if (!empty($user['id'])) {
                        $fbo['fbAppAuthUser'] = $user['id'];
                        $fbo['fbAppAuthUserName'] = $user['name'] . (!empty($user['username']) ? " (" . $user['username'] . ")" : '');
                        if (function_exists('get_option')) {
                            $nxs_gOptions = get_option('NS_SNAutoPoster');
                        }
                        if (!empty($nxs_gOptions)) {
                            $nxs_gOptions['fb'][$ii] = $fbo;
                            nxs_settings_save($nxs_gOptions);
                        }
                        ?>
<script type="text/javascript">window.location = "<?php 
                        echo $nxs_snapSetPgURL;
                        ?>
"</script>      
      <?php 
                    }
                    die;
                }
            }
            $ntParams = array('ntInfo' => $ntInfo, 'nxs_plurl' => $nxs_plurl, 'ntOpts' => $ntOpts, 'chkField' => 'fbAppAuthUser');
            nxs_showListRow($ntParams);
        }