示例#1
0
文件: export.php 项目: xxf1995/alphaV
 function denglu_exportComment_ajax($start = 0)
 {
     @ini_set("max_execution_time", 300);
     if (function_exists('import_comments_to_denglu')) {
         $data = import_comments_to_denglu();
     } else {
         return var_dump("请先在评论设置勾选开启“社会化评论”功能。");
     }
     // $data = array_slice(range(1,605), $start, 50, true);
     // sleep(1);
     // return var_dump($data);
     if ($data) {
         $wptm_basic = get_option('wptm_basic');
         $data = json_encode($data);
         class_exists('Denglu') or (require dirname(__FILE__) . "/class/Denglu.php");
         $api = new Denglu($wptm_basic['appid'], $wptm_basic['appkey'], 'utf-8');
         try {
             $comments = $api->importComment($data);
         } catch (DengluException $e) {
             // 获取异常后的处理办法(请自定义)
             // wp_die($e -> geterrorDescription()); //返回错误信息
             echo $e->geterrorDescription();
             return;
         }
         // return var_dump($comments);
         if ($comments && is_array($comments)) {
             foreach ($comments as $comment) {
                 if ($comment['id']) {
                     wp_update_comment_agent($comment['comment_ID'], $comment['id']);
                 }
                 if (is_array($comment['children'])) {
                     foreach ($comment['children'] as $children) {
                         if ($children['id']) {
                             wp_update_comment_agent($children['comment_ID'], $children['id']);
                         }
                     }
                 }
             }
             echo count($comments) + $start;
             //继续
         }
     } else {
         echo 'success';
         //成功
     }
 }
示例#2
0
 function denglu_importReplyComment($comment_id, $comment)
 {
     if ($comment->comment_approved != 1 || $comment->comment_type == 'trackback' || $comment->comment_type == 'pingback' || $comment->comment_parent == 0 || strpos($comment->comment_agent, 'Denglu_') !== false) {
         return $comment_id;
     }
     $get_dlCommentID = get_dengluCommentID($comment->comment_parent);
     if ($get_dlCommentID) {
         $comment = array('comment_ID' => $comment->comment_ID, 'comment_post_ID' => $comment->comment_post_ID, 'comment_author' => $comment->comment_author, 'comment_author_email' => $comment->comment_author_email, 'comment_author_url' => $comment->comment_author_url, 'comment_author_IP' => $comment->comment_author_IP, 'comment_date' => $comment->comment_date, 'comment_content' => $comment->comment_content, 'comment_parent' => $comment->comment_parent, 'user_id' => $comment->user_id);
         if ($comment['user_id']) {
             if ($tid = get_usertid($comment['comment_author_email'], $comment['user_id'])) {
                 $user = get_row_userinfo($comment['user_id'], $tid);
                 if (is_array($user)) {
                     $comment = array_merge($user, $comment);
                 }
             }
         }
         $data[] = array('cid' => $get_dlCommentID, 'children' => array($comment));
         $data = json_encode($data);
         class_exists('Denglu') or (require dirname(__FILE__) . "/class/Denglu.php");
         global $wptm_basic;
         $api = new Denglu($wptm_basic['appid'], $wptm_basic['appkey'], 'utf-8');
         try {
             $comments = $api->importComment($data);
         } catch (DengluException $e) {
             // 获取异常后的处理办法(请自定义)
         }
         // return var_dump($comments);
         if (is_array($comments)) {
             foreach ($comments as $comment) {
                 if (is_array($comment['children'])) {
                     foreach ($comment['children'] as $children) {
                         if ($children['id']) {
                             wp_update_comment_agent($children['comment_ID'], $children['id']);
                         }
                     }
                 }
             }
         }
     }
 }
示例#3
0
<?php

/*
 *加载文件
 */
require_once dirname(__FILE__) . '\\Denglu.php';
$appID = '52707denh7xFHpBYtEUEhgnOk6zOi3';
$apiKey = '49934527EwK9aB7bakQvsft2SiJUuA';
$charset = 'utf-8';
/*
 *初始化接口类Denglu
 */
$api = new Denglu($appID, $apiKey, $charset);
/*
 *调用接品类相关方法获取媒体用户信息示例
 */
/*
"mediaID":7,							// 媒体ID
	 * 		"createTime":"2011-05-20 16:44:19",		// 创建时间
	 * 		"friendsCount":0,						// 好友数
	 * 		"location":null,						// 地址
	 * 		"favouritesCount":0,					// 收藏数
	 * 		"screenName":"denglu",					// 显示姓名
	 * 		"profileImageUrl":"http://head.xiaonei.com/photos/0/0/men_main.gif",		// 个人头像
	 * 		"mediaUserID":61,						// 用户ID
	 * 		"url":null,								// 用户博客/主页地址
	 * 		"city":null,							// 城市
	 * 		"description":null,						// 个人描述
	 * 		"createdAt":"",							// 在媒体上的创建时间
	 * 		"verified":0,							// 认证标志
	 * 		"name":null,							// 友好显示名称