コード例 #1
0
ファイル: RLPlurkAPI.php プロジェクト: AndyA/WWW--Plurk
 /**
  * Get the responses of a plurk. This method will load "temporary" friends 
  * who have responded to the plurk.
  *
  * @param int $int_plurk_id The plurk ID 
  *
  * @return array The array of responses.
  */
 function getResponses($int_plurk_id)
 {
     $this->http_client->post($this->plurk_paths['getResponses'], array('plurk_id' => $int_plurk_id));
     $data = $this->http_client->currentResponse();
     $string_response = $data['body'];
     $data = explode('"responses": ', $string_response);
     preg_match('/\\{"friends": \\{"\\d+": (.*)\\}, "responses/', $data[0], $local_friend);
     if (isset($local_friend[1])) {
         $temp_friends = array();
         $each_friend_almost_json = preg_split('/\\}, "\\d+": \\{/', $local_friend[1]);
         foreach ($each_friend_almost_json as $friend_data) {
             if (substr($friend_data, 0, 1) != '{') {
                 $friend_data = '{' . $friend_data;
             }
             if (substr($friend_data, strlen($friend_data) - 1, strlen($friend_data)) != '}') {
                 $friend_data = $friend_data . '}';
             }
             $temp_friends = array_merge($temp_friends, RLPlurkAPI::dejsonize($friend_data));
         }
         $this->friends = array_merge($this->friends, $temp_friends);
     }
     $responses = array();
     if (isset($data[1])) {
         $response_data = substr($data[1], 0, strlen($data[1]) - 1);
         $responses = RLPlurkAPI::dejsonize($response_data);
         foreach ($responses as &$each_response) {
             $each_response['nick_name'] = $this->uidToNickname($each_response['user_id']);
         }
     }
     return $responses;
 }
コード例 #2
0
ファイル: example.php プロジェクト: AndyA/WWW--Plurk
<?php

$nick_name = 'johndoe';
$password = '******';
require 'RLPlurkAPI.php';
$plurk = new RLPlurkAPI();
$plurk->login($nick_name, $password);
// these are my friends/fans
print_r($plurk->friends);
//echo "\n\n------ getAlerts ------\n";
//echo "These are the friend requests you have:\n";
//$alerts = $plurk->getAlerts();
//print_r($alerts);
// Uncomment to accept all friend requests from the alert queue.
//$plurk->befriend($alerts, true);
// Uncomment to deny all friend requests from the alert queue.
//$plurk->befriend($alerts, false);
/*
 * Get my plurks.
 */
//echo "\n\n------ getUnreadPlurks ------\n";
//print_r($plurk->getUnreadPlurks(true));
//echo "\n\n------ getPlurks ------\n";
//print_r($plurk->getPlurks($plurk->uid));
// get plurks with responses from a certain time.
//print_r($plurk->getPlurks($plurk->uid, '2008-02-01T01:10:00', '2008-02-01T01:00:00'));
//echo "\n\n------ addPlurk ------\n";
//$plurk->addPlurk('en', 'is', 'tired (:');
//echo "\n\n------ respondToPlurk ------\n";
//echo $plurk->respondToPlurk(RLPlurkAPI::permalinkToPlurkID(___permalink_url___), 'en', 'says', 'test from RLPlurkAPI');
//echo "\n\n------ getResponses ------\n";