function get_friends($appkey, $appsecret, $session_key, $page = 1, $count = 500) { $rrObj = new RenRenClient(); $rrObj->init($appkey, $appsecret); $rrObj->setSessionKey($session_key); $result = $rrObj->POST('friends.getFriends', array($page, $count)); return $result; }
function getUserInfo() { $rrObj = new RenRenClient(); $rrObj->setSessionKey($re->session_key); $rs = $rrObj->POST('users.getInfo', array($this->renuid, 'uid,name,sex,star,birthday,tinyurl,headurl,mainurl,hometown_location')); $this->me = $rs[0]; $user['uid'] = $me->uid; $user['name'] = $me->screen_name; $user['sex'] = $me->sex ? '男' : '女'; $user['pic'] = $me->headurl; $user['province'] = $me->hometown_location->province; $user['city'] = str_replace('市', '', $me->hometown_location->city); return $this->user; }
<?php session_start(); require_once '../class/requires.php'; // 需要数据 //插入时间,同时用来查找用户。 $timein = time(); for ($i = 1; $i < count($_POST['sendString']); $i++) { $_POST['json_en'][$i] = $_POST['sendString'][$i]; } // print_r($_POST['sendString']); $_POST['shareContent'] = "<a href = 'www.baidu.com'>我在百度玩玩而已</a>"; $client = new RenRenClient(); $session_key = $_SESSION['key']['renren_token']['session_key']; $client->setSessionKey($session_key); //获取用户信息 $us = $client->POST('users.getInfo', array("uid,name,sex,star,zidou,vip,birthday,tinyurl,headurl,mainurl,hometown_location\rwork_history,university_history")); // print_r($us); //数据入库 include_once '../class/db.class.php'; $db = new DB(); //用户入库 $sql_arr = array(); $sql_arr['name'] = $us[0]['name']; $sql_arr['sex'] = $us[0]['sex']; $sql_arr['birthday'] = $us[0]['birthday']; $sql_arr['university'] = $us[0]['university_history'][0]['name']; $sql_arr['answers'] = json_encode($_POST['json_en']); $sql_arr['time'] = $timein; print_r($db->insert('users', $sql_arr)); // 答案入库
* The requirement of PHP version is 5.2.0 or above, and support as below: * cURL, Libxml 2.6.0 * * @Version: 0.0.2 alpha * @Created: 0:11:39 2010/11/25 * @Author: Edison tsai<*****@*****.**> * @Blog: http://www.timescode.com * @Link: http://www.dianboom.com */ require_once 'RenRenClient.class.php'; $rrObj = new RenRenClient(); /* *@获取指定用户的信息 *@POST暂时有两个参数,第一个是需要调用的方法,具体的方法跟人人网的API一致,注意区分大小写 *@第二个参数是一维数组,顺序排列必须跟config.inc.php文件中的$config->APIMapping设置一样,否则会出现异常 */ /* @Setting session_key example(设置session_key的例子) @Don't need to setSessionKey when you are logged in @如果你登录了就不需要设置session_key,RenRenClient类会自行获取,以下方法只是为了自由扩展而设置的 */ $rrObj->setSessionKey('3.c149c48e2c18d48c0110434f3189e070.21600.1294927200-346132863'); /* @Setting call_id example(设置call_id的例子) @Just for extension,只是为了扩展使用,能结合你自身系统的一些队列流水号来使用,然后做一些数据跟踪 */ $rrObj->setCallId('12345678'); #Example 1 (一般的使用例子,已经把call_id 及 session_key封装进去了) $res = $rrObj->POST('users.getInfo', array('346132863,741966903', 'uid,name,tinyurl,headhurl,zidou,star')); print_r($res); #See source code for get more info(查看源码来获取更多的信息)