Inheritance: extends HttpRequestService
Ejemplo n.º 1
0
 /**
  * renren发布一条新鲜事
  */
 public function addRenrenFeed($bindinfo, $params)
 {
     include_once BasePath . DS . 'api' . DS . 'snsapi' . DS . 'renren' . DS . 'class' . DS . 'RenrenRestApiService.class.php';
     $params_renren = array();
     $params_renren['access_token'] = $bindinfo['snsbind_accesstoken'];
     $params_renren['name'] = $params['title'];
     $params_renren['description'] = $params['comment'];
     $params_renren['url'] = $params['url'];
     $params_renren['image'] = $params['images'];
     $renren_obj = new RenrenRestApiService();
     $renren_obj->rr_post_fopen('feed.publishFeed', $params_renren);
 }
Ejemplo n.º 2
0
 public function update($text, $opt)
 {
     require_once 'renren/HttpRequestService.class.php';
     require_once 'renren/RenrenRestApiService.class.php';
     $refresh_uri = 'https://graph.renren.com/oauth/token?grant_type=refresh_token&refresh_token=' . $opt["oauth_token_secret"] . '&client_id=' . RENREN_KEY . '&client_secret=' . RENREN_SECRET;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $refresh_uri);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $result = curl_exec($ch);
     $res = json_decode($result);
     $access_token = $res->access_token;
     $refresh_token = $res->refresh_token;
     $config = new stdClass();
     $config->APIURL = 'http://api.renren.com/restserver.do';
     $config->APIKey = RENREN_KEY;
     $config->SecretKey = RENREN_SECRET;
     $config->APIVersion = '1.0';
     $config->decodeFormat = 'json';
     $GLOBALS['config'] =& $config;
     $rrObj = new RenrenRestApiService();
     $params = array('name' => getShort($opt["feed_content"], 30), 'description' => $opt["feed_content"], 'url' => $opt["feed_url"], 'image' => $opt["pic_url"], 'action_name' => $GLOBALS['ts']['site']['site_name'], 'action_link' => $opt["feed_url"], 'message' => '分享', 'access_token' => $access_token);
     $res = $rrObj->rr_post_curl('feed.publishFeed', $params);
     return true;
 }
Ejemplo n.º 3
0
 * 调用人人网RESTful API的范例,本类需要继承RESTClient类方可使用
 * 要求最低的PHP版本是5.2.0,并且还要支持以下库:cURL, Libxml 2.6.0
 * This example for invoke RenRen RESTful Webservice
 * It MUST be extends RESTClient
 * The requirement of PHP version is 5.2.0 or above, and support as below:
 * cURL, Libxml 2.6.0
 *
 * @Modified by mike on 17:54 2011/12/21.
 * @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 'renrenRestApiService.class.php';
$rrObj = new RenrenRestApiService();
//sessionkey和accesstoken,传任何一个都可以;“测试1”用的是sessionkey,“测试2”用的是accesstoken
$sessionkey = '6.c15fbc6fd142dddce6bd98a4d5524286.2592000.1327053600-228487955';
//改成测试用户的
$accesstoken = '99273|6.c15fbc6fd142dddce6bd98a4d5524286.2592000.1327053600-228487955';
//改成测试用户的
//$rrObj->setEncode("GB2312");//如果是utf-8的环境可以不用设,如果当前环境不是utf8编码需要在这里设定
/*@POST暂时有两个参数,第一个是需要调用的方法,具体的方法跟人人网的API一致,注意区分大小写
 *@第二个参数是一维数组,除了api_key,method,v,format,callid之外的其他参数/

/*测试1:获取指定用户的信息
 */
$params = array('uids' => '346132863,741966903', 'fields' => 'uid,name,sex,birthday,mainurl,hometown_location,tinyurl,headurl,mainurl', 'session_key' => $sessionkey);
//使用session_key调api的情况
$res = $rrObj->rr_post_curl('users.getInfo', $params);
//curl函数发送请求