public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $status = $ms->getStatus("@me"); $this->assertTrue($status != NULL, "Status Failed"); $statusHistory = $ms->getStatusHistory("@me"); $this->assertTrue(count($statusHistory) >= 0, "History Failed"); $friendstatusHistory = $ms->getFriendsStatusHistory("@me"); $this->assertTrue(count($friendstatusHistory) >= 0, "History Failed"); $friendstatusHistory = $ms->getFriendsStatusHistory("@me"); $this->assertTrue(count($friendstatusHistory) >= 0, "Friends History Failed"); if (count($friends) > 0) { $friendId = FRIEND_ID; $friendStatus = $ms->getFriendsStatus("@me", $friendId); $this->assertTrue(count($friendStatus) >= 0, "Status By Friend ID Failed"); $fhistory = $ms->getFriendStatusHistory("@me", $friendId); $this->assertTrue(count($fhistory) >= 0, "Status History By Friend ID Failed"); } $moods = $ms->getSupportedStatus("@me"); $this->assertTrue(count($moods) >= 0, "Supported Status Failed"); if (count($moods) > 0) { $mood = $ms->getSupportedStatusById("@me", $moods->array[0]->moodId); $this->assertTrue($mood != NULL, "Supported Status Mood By Id Failed"); } $uStatus = $ms->updateStatus("@me", "excited", "Hi Mood", array('latitude' => 47.604832, 'longitude' => -122.337549)); $this->assertTrue($uStatus != NULL, "Update Status Failed"); }
public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $comments = $ms->getProfileComments("@me"); $this->assertTrue($comments != NULL, "Profile Comments Failed"); }
public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $userid = $ms->getCurrentUserId(); $this->assertTrue($userid != 0); }
public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $userId = $ms->getCurrentUserId(); $notification = $ms->sendNotification($userId, $userId, array('content' => 'this is content'), 'http://opensocial.myspace.com/roa/09/mediaitemcomments/'); $this->assertTrue($notification->statusLink != NULL, "Send Notification Failed"); }
public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $groups = $ms->getGroups("@me"); $this->assertTrue(count($groups) >= 0); $fields = $ms->getGroupsSupportedFields(); $this->assertTrue(count($fields) > 0); }
public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $person = $ms->getPersonPoco("@me"); $this->assertTrue($person != NULL, "Person POCO Failed"); $friendPoco = $ms->getFriendsPoco("@me"); $this->assertTrue($friendPoco != NULL, "Friend POCO Failed"); }
public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $subscription = $ms->addSubscription('All', 'http://myspace.si-sv2826.com/myposthandler.ashx', '{}', '', 100, 100); $this->assertTrue($subscription->statusLink != NULL, "Subscription Failed"); $getsubscription = $ms->getAllSubscription(); $this->assertTrue($getsubscription != NULL, "Get All Subscription Failed"); $deleteSubscription = $ms->deleteAllSubscription(); $this->assertTrue($getsubscription == 1, "Delete All Subscription Failed"); }
public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $fields = $ms->getPeopleSupportedFields(); $this->assertTrue(count($fields) > 0); $people = $ms->getPerson("@me"); $this->assertTrue($people->person - id != NULL); $friends = $ms->getFriends("@me"); $this->assertTrue(count($friends) >= 0); }
public function test_pass() { $ms_key = CONSUMER_KEY; //we get this from config.MySpace.php $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $peopleSearch = $ms->searchPeople("car"); $this->assertTrue($peopleSearch != NULL, "People Search Failed"); $imageSearch = $ms->searchImages("car"); $this->assertTrue($imageSearch != NULL, "Image Search Failed"); $videoSearch = $ms->searchVideos("car"); $this->assertTrue($videoSearch != NULL, "Video Search Failed"); }
function run() { $consumer = getConsumer(); // Complete the authentication process using the server's // response. $return_to = getReturnTo(); $response = $consumer->complete($return_to); // Check the response status. if ($response->status == Auth_OpenID_CANCEL) { // This means the authentication was cancelled. $msg = 'Verification cancelled.'; } else { if ($response->status == Auth_OpenID_FAILURE) { // Authentication failed; display the error message.d $msg = "OpenID authentication failed: " . $response->message; } else { if ($response->status == Auth_OpenID_SUCCESS) { // This means the authentication succeeded; extract the // identity URL and Simple Registration data (if it was // returned). $openid = $response->getDisplayIdentifier(); $esc_identity = escape($openid); $success = sprintf('You have successfully verified ' . '<a href="%s">%s</a> as your identity.<br><br>Here\'s your MySpace profile data fetched using the MySpace REST APIs', $esc_identity, $esc_identity); if ($response->endpoint->canonicalID) { $escaped_canonicalID = escape($response->endpoint->canonicalID); $success .= ' (XRI CanonicalID: ' . $escaped_canonicalID . ') '; } $oauth_resp = Auth_OpenID_OAuthResponse::fromSuccessResponse($response); $authorized_request_token = $oauth_resp->authorized_request_token; //1.0A OAuth Spec, we will need this to get an access token $authorized_verifier = $oauth_resp->authorized_verifier; if ($authorized_request_token) { $ms = new MySpace(CONSUMER_KEY, CONSUMER_SECRET, $authorized_request_token->key, $authorized_request_token->secret, $authorized_verifier); $access_token = $ms->getAccessToken(); $ms = new MySpace(CONSUMER_KEY, CONSUMER_SECRET, $access_token->key, $access_token->secret); $userid = $ms->getCurrentUserId(); // Use the userID (fetched in the previous step) to get user's profile, friends and other info $profile_data = $ms->getProfile($userid); $friends_data = $ms->getFriends($userid); $ms->updateStatus($userid, 'testing sdk'); // Access $profile_data and $friend_data inside of index.php (via the include below) // to display the profile/friends data } } } } include 'index.php'; }
public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $appId = APP_ID; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $userid = $ms->getCurrentUserId(); $getApp = $ms->getAppData("@me", $appId); $this->assertTrue(count($getApp) >= 0, "Get App Data Failed"); $addApp = $ms->addAppData("@me", $appId, 'test', 'values23'); $this->assertEqual($addApp->statusLink != NULL, "Add App Data Failed"); $delApp = $ms->clearAppData("@me", $appId, 'test'); $this->assertEqual($delApp == 1, "Delete App Data Failed"); }
public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $albums = $ms->getAlbums("@me"); if (count($albums) >= 0) { $getMediaItem = $ms->getMediaItems("@me", $albums->entry[0]->album->id); if (count($getMediaItem) >= 0) { $comments = $ms->getMediaItemComments("@me", $albums->entry[0]->album->id, $getMediaItem->entry[0]->mediaItem->id); $this->assertTrue(count($comments) >= 0, "Get Media Item Comments Failed"); } } }
public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $mediaFields = $ms->getMediaItemSupportedFields(); $this->assertTrue(count($mediaFields) != 0); $albums = $ms->getAlbums("@me"); $this->assertTrue(count($albums) >= 0); if (count($albums) >= 0) { $getMediaItem = $ms->getMediaItems("@me", $albums->entry[0]->album->id); $this->assertTrue(count($getMediaItems) >= 0); if (count($getMediaItem) >= 0) { $itemById = $ms->getMediaItemById("@me", $albums->entry[0]->album->id, $getMediaItem->entry[0]->mediaItem->id); $this->assertEqual($getMediaItem->entry[0]->mediaItem->id, $itemById->mediaItem->id, "Get Media Item By Id Failed"); } } $videoCategories = $ms->getVideosCategories("@me"); $this->assertTrue(count($videoCategories) > 0, "Get Videos Categories Failed"); if (count($videoCategories) >= 0) { $videoCategoriesById = $ms->getVideosCategoriesById("@me", $videoCategories->array[0]->id); $this->assertTrue(count($videoCategoriesById) >= 0, "Get Video Catgegories By Id"); } }
function testNET_API_MySpace() { $MySpace = new MySpace(); // login to Kokaina profile $res = $MySpace->Login('*****@*****.**', 'sdfsdfs'); $this->assertTrue($res, "Can't login to MySpace"); // get account number $res = $MySpace->GetAccountID(); $this->assertTrue($res, "Can't get user ID"); // get friends list // need a lot of time (for all pages) $res = $MySpace->GetFriendsList2(129591806); // 1520 records (38 pages) on 78646455 $this->assertTrue($res && count($res), "Can't get friends list from myspace"); if (!$res) { var_dump($MySpace->Result); } // get blog entries $res = $MySpace->GetBlogEntries(); $this->assertTrue($res, "Can't get blog entries from myspace"); if (!$res) { var_dump($MySpace->Result); } // get profile object $Profile = $MySpace->GetProfileByID(); $this->assertTrue($Profile, "Can't get user profile"); if (!$Profile) { var_dump($MySpace->Result); } // get country from profile object $Profile->GetPersonalDetails(); $this->assertEqual($Profile->Country, 'Tokelau', "Country isn't Takelau"); /* end of tests*/ }
public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $userid = $ms->getCurrentUserId(); $fields = $ms->getActivitiesSupportedFields(); $this->assertTrue(count($fields) > 0); $verbs = $ms->getActivitiesSupportedVerbs(); $this->assertTrue(count($verbs) > 0); $types = $ms->getActivitiesSupportedTypes(); $this->assertTrue(count($types) > 0); $activites = $ms->getActivities($userid); $this->assertTrue(count($activities) >= 0); $friendActivities = $ms->getFriendsActivities($userid); $this->assertTrue(count($friendActivities) >= 0); }
public function test_pass() { $ms_key = CONSUMER_KEY; $ms_secret = CONSUMER_SECRET; $token = OAUTH_TOKEN; $secret = OAUTH_SECRET; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $albumFields = $ms->getAlbumsSupportedFields(); $this->assertTrue(count($albumFields) != 0); $albums = $ms->getAlbums("@me"); $this->assertTrue(count($albums) >= 0); $addAlbum = $ms->addAlbum("@me", "myalbum"); $this->assertTrue($addAlbum->statusLink != NULL); if (count($albums) >= 0) { $updateAlbum = $ms->updateAlbum("@me", $albums->entry[0]->album->id, "myalbum2"); $this->assertTrue($updateAlbum->statusLink != NULL); $album = $ms->getAlbum("@me", $albums->entry[0]->album->id); $this->assertEqual($album->album->id, $albums->entry[0]->album->id); } }
require_once '../global.inc.php'; $action = $_GET['a']; //if (!api_is_platform_admin() && !api_is_xml_http_request()) { exit; } require_once api_get_path(SYS_CODE_PATH) . 'mySpace/myspace.lib.php'; switch ($action) { case 'access_detail': $user_id = intval($_REQUEST['student']); $course_code = Security::remove_XSS($_REQUEST['course']); $type = Security::remove_XSS($_REQUEST['type']); $range = Security::remove_XSS($_REQUEST['range']); if ($range == 1) { $start_date = Security::remove_XSS($_REQUEST['sd']); $end_date = Security::remove_XSS($_REQUEST['ed']); $sql_result = get_connections_to_course_by_date($user_id, $course_code, $start_date, $end_date); } else { $sql_result = MySpace::get_connections_to_course($user_id, $course_code); } $foo_print = grapher($sql_result, $start_date, $end_date, $type); echo $foo_print; break; case 'access_detail_by_date': $db = array('is_empty' => true); $start_date = isset($_REQUEST['startDate']) ? $_REQUEST['startDate'] : ""; $end_date = isset($_REQUEST['endDate']) ? $_REQUEST['endDate'] : ""; $user_id = isset($_REQUEST['student']) ? $_REQUEST['student'] : ""; $course_code = isset($_REQUEST['course']) ? $_REQUEST['course'] : ""; $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : ""; $sql_result = get_connections_to_course_by_date($user_id, $course_code, $start_date, $end_date); if (is_array($sql_result) && count($sql_result) > 0) { $db['is_empty'] = false; $db['result'] = convert_to_string($sql_result);
$form->setDefaults(array('session_id' => $session_id)); $course_list = SessionManager::get_course_list_by_session_id($session_id); if (!$export_to_xls) { Display::display_header(get_lang("MySpace")); echo '<div class="actions">'; if ($global) { echo MySpace::getTopMenu(); } else { echo '<div style="float:left; clear:left"> <a href="courseLog.php?' . api_get_cidreq() . '&studentlist=true">' . get_lang('StudentsTracking') . '</a> | <a href="courseLog.php?' . api_get_cidreq() . '&studentlist=false">' . get_lang('CourseTracking') . '</a> '; echo '</div>'; } echo '</div>'; if (api_is_platform_admin()) { echo MySpace::getAdminActions(); } echo '<h2>' . get_lang('LPExerciseResultsBySession') . '</h2>'; $form->display(); Display::display_normal_message(get_lang('StudentScoreAverageIsCalculatedBaseInAllLPsAndAllAttempts')); } $users = SessionManager::get_users_by_session($session_id); $course_average = $course_average_counter = array(); $counter = 0; $main_result = array(); //Getting course list foreach ($course_list as $current_course) { $course_info = api_get_course_info($current_course['code']); $_course = $course_info; $attempt_result = array(); //Getting LP list
if ($display == 'useroverview') { echo ' ( <a href="' . api_get_self() . '?view=admin&display=useroverview&export=options">' . get_lang('ExportUserOverviewOptions') . '</a> )'; } echo ' | <a href="' . api_get_self() . '?view=admin&display=sessionoverview">' . get_lang('DisplaySessionOverview') . '</a>'; echo ' | <a href="' . api_get_self() . '?view=admin&display=courseoverview">' . get_lang('DisplayCourseOverview') . '</a>'; echo ' | <a href="' . api_get_path(WEB_CODE_PATH) . 'tracking/question_course_report.php?view=admin">' . get_lang('LPQuestionListResults') . '</a>'; echo ' | <a href="' . api_get_path(WEB_CODE_PATH) . 'tracking/course_session_report.php?view=admin">' . get_lang('LPExerciseResultsBySession') . '</a>'; echo '<br /><br />'; if ($display === 'useroverview') { MySpace::display_tracking_user_overview(); } else { if ($display == 'sessionoverview') { MySpace::display_tracking_session_overview(); } else { if ($display == 'courseoverview') { MySpace::display_tracking_course_overview(); } else { if ($export_csv) { $is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT); } else { $is_western_name_order = api_is_western_name_order(); } $sort_by_first_name = api_sort_by_first_name(); $tracking_column = isset($_GET['tracking_list_coaches_column']) ? $_GET['tracking_list_coaches_column'] : ($is_western_name_order xor $sort_by_first_name) ? 1 : 0; $tracking_direction = isset($_GET['tracking_list_coaches_direction']) && in_array(strtoupper($_GET['tracking_list_coaches_direction']), array('ASC', 'DESC', 'ASCENDING', 'DESCENDING', '0', '1')) ? $_GET['tracking_list_coaches_direction'] : 'DESC'; // Prepare array for column order - when impossible, use some of user names. if ($is_western_name_order) { $order = array(0 => 'firstname', 1 => 'lastname', 2 => $sort_by_first_name ? 'firstname' : 'lastname', 3 => 'login_date', 4 => $sort_by_first_name ? 'firstname' : 'lastname', 5 => $sort_by_first_name ? 'firstname' : 'lastname'); } else { $order = array(0 => 'lastname', 1 => 'firstname', 2 => $sort_by_first_name ? 'firstname' : 'lastname', 3 => 'login_date', 4 => $sort_by_first_name ? 'firstname' : 'lastname', 5 => $sort_by_first_name ? 'firstname' : 'lastname'); }
/** * Saves imported data. */ public function save_data($users, $course_list, $id_session) { $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); $id_session = intval($id_session); $sendMail = $_POST['sendMail'] ? 1 : 0; // Adding users to the platform. $new_users = array(); foreach ($users as $index => $user) { $user = MySpace::complete_missing_data($user); // coach only will registered users $default_status = STUDENT; if ($user['create'] == COURSEMANAGER) { $user['id'] = UserManager::create_user($user['FirstName'], $user['LastName'], $default_status, $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('language.platform_language'), $user['PhoneNumber'], ''); $user['added_at_platform'] = 1; } else { $user['id'] = $user['create']; $user['added_at_platform'] = 0; } $new_users[] = $user; } // Update user list. $users = $new_users; // Inserting users. $super_list = array(); foreach ($course_list as $enreg_course) { $nbr_users = 0; $new_users = array(); $enreg_course = Database::escape_string($enreg_course); foreach ($users as $index => $user) { $userid = intval($user['id']); $sql = "INSERT IGNORE INTO {$tbl_session_rel_course_rel_user}(session_id, c_id, user_id)\n VALUES('{$id_session}','{$enreg_course}','{$userid}')"; $course_session = array('course' => $enreg_course, 'added' => 1); $result = Database::query($sql); if (Database::affected_rows($result)) { $nbr_users++; } $new_users[] = $user; } $super_list[] = $new_users; //update the nbr_users field $sql_select = "SELECT COUNT(user_id) as nbUsers FROM {$tbl_session_rel_course_rel_user}\n WHERE session_id='{$id_session}' AND c_id='{$enreg_course}'"; $rs = Database::query($sql_select); list($nbr_users) = Database::fetch_array($rs); $sql_update = "UPDATE {$tbl_session_rel_course} SET nbr_users={$nbr_users}\n WHERE session_id='{$id_session}' AND c_id='{$enreg_course}'"; Database::query($sql_update); $sql_update = "UPDATE {$tbl_session} SET nbr_users= '{$nbr_users}' WHERE id='{$id_session}'"; Database::query($sql_update); } $new_users = array(); foreach ($users as $index => $user) { $userid = $user['id']; $sql_insert = "INSERT IGNORE INTO {$tbl_session_rel_user}(session_id, user_id, registered_at)\n VALUES ('{$id_session}','{$userid}', '" . api_get_utc_datetime() . "')"; Database::query($sql_insert); $user['added_at_session'] = 1; $new_users[] = $user; } $users = $new_users; $registered_users = get_lang('FileImported') . '<br /> Import file results : <br />'; // Sending emails. $addedto = ''; if ($sendMail) { $i = 0; foreach ($users as $index => $user) { $emailsubject = '[' . api_get_setting('platform.site_name') . '] ' . get_lang('YourReg') . ' ' . api_get_setting('platform.site_name'); $emailbody = get_lang('Dear') . ' ' . api_get_person_name($user['FirstName'], $user['LastName']) . ",\n\n" . get_lang('YouAreReg') . " " . api_get_setting('platform.site_name') . " " . get_lang('WithTheFollowingSettings') . "\n\n" . get_lang('Username') . " : {$user['UserName']}\n" . get_lang('Pass') . " : {$user['Password']}\n\n" . get_lang('Address') . " " . api_get_setting('platform.site_name') . " " . get_lang('Is') . " : " . api_get_path(WEB_PATH) . " \n\n" . get_lang('Problem') . "\n\n" . get_lang('SignatureFormula') . ",\n\n" . api_get_person_name(api_get_setting('admin.administrator_name'), api_get_setting('admin.administrator_surname')) . "\n" . get_lang('Manager') . " " . api_get_setting('platform.site_name') . "\nT. " . api_get_setting('admin.administrator_phone') . "\n" . get_lang('Email') . " : " . api_get_setting('admin.administrator_email'); api_mail_html(api_get_person_name($user['FirstName'], $user['LastName'], null, PERSON_NAME_EMAIL_ADDRESS), $user['Email'], $emailsubject, $emailbody); $userInfo = api_get_user_info($user['id']); if ($user['added_at_platform'] == 1 && $user['added_at_session'] == 1 || $user['added_at_session'] == 1) { if ($user['added_at_platform'] == 1) { $addedto = get_lang('UserCreatedPlatform'); } else { $addedto = ' '; } if ($user['added_at_session'] == 1) { $addedto .= get_lang('UserInSession'); } } else { $addedto = get_lang('UserNotAdded'); } $registered_users .= UserManager::getUserProfileLink($userInfo) . " - " . $addedto . '<br />'; } } else { $i = 0; foreach ($users as $index => $user) { $userInfo = api_get_user_info($user['id']); if ($user['added_at_platform'] == 1 && $user['added_at_session'] == 1 || $user['added_at_session'] == 1) { if ($user['added_at_platform'] == 1) { $addedto = get_lang('UserCreatedPlatform'); } else { $addedto = ' '; } if ($user['added_at_session'] == 1) { $addedto .= ' ' . get_lang('UserInSession'); } } else { $addedto = get_lang('UserNotAdded'); } $registered_users .= "<a href=\"../user/userInfo.php?uInfo=" . $user['id'] . "\">" . api_get_person_name($user['FirstName'], $user['LastName']) . "</a> - " . $addedto . '<br />'; } } header('Location: course.php?id_session=' . $id_session . '&action=show_message&message=' . urlencode($registered_users)); exit; }
$nameTools = get_lang('MyProgress'); api_block_anonymous_users(); $htmlHeadXtra[] = api_get_js('jquery.timelinr-0.9.5.js'); $htmlHeadXtra[] = ' <script language="javascript"> $(function() { $().timelinr(); }); </script>'; $user_id = api_get_user_id(); $course_user_list = CourseManager::get_courses_list_by_user_id($user_id); $dates = $issues = ''; $sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0; $courseCode = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null; if (!empty($course_user_list)) { $items = MySpace::get_connections_from_course_list($user_id, $course_user_list); $first = null; $last = null; $last_item = count($items); $count = 1; foreach ($items as $result) { $login = $result['login']; $courseId = $result['c_id']; $courseInfo = api_get_course_info_by_id($courseId); if ($count == 1) { $first = '<a href="#' . $login . '">' . get_lang('First') . '</a>'; } if ($count == $last_item) { $last = '<a href="#' . $login . '">' . get_lang('Last') . '</a>'; } $course_info = api_get_course_info_by_id($result['c_id']);
$css_class = "row_even"; } $i++; if ($is_western_name_order) { $data[$user_id]["firstname"] = $firstname; $data[$user_id]["lastname"] = $lastname; } else { $data[$user_id]["lastname"] = $lastname; $data[$user_id]["firstname"] = $firstname; } $time_on_platform = api_time_to_hms(Tracking::get_time_spent_on_the_platform($user_id, $time_filter, $start_date, $end_date)); $data[$user_id]["timespentlastweek"] = $time_on_platform; $data[$user_id]["email"] = $email; if ($is_western_name_order) { echo '<tr class="' . $css_class . '"><td>' . $firstname . '</td><td>' . $lastname . '</td><td align="right">' . $time_on_platform . '</td><td align="right"><a href="mailto:' . $email . '">' . $email . '</a></td><td align="right"><a href="course.php?user_id=' . $user_id . '"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a></td><td align="right"><a href="student.php?user_id=' . $user_id . '&display=yourstudents"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a></td></tr>'; } else { echo '<tr class="' . $css_class . '"><td>' . $lastname . '</td><td>' . $firstname . '</td><td align="right">' . $time_on_platform . '</td><td align="right"><a href="mailto:' . $email . '">' . $email . '</a></td><td align="right"><a href="course.php?user_id=' . $user_id . '"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a></td><td align="right"><a href="student.php?user_id=' . $user_id . '&display=yourstudents"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a></td></tr>'; } } } else { // No results echo '<tr><td colspan="6">' . get_lang("NoResults") . '</td></tr>'; } echo '</table>'; if (isset($_POST['export']) || api_is_drh() && isset($_GET['export'])) { MySpace::export_csv($header, $data, 'teachers.csv'); } if (!api_is_drh()) { echo "<form method='post' action='teachers.php'>\n <input type='submit' class='btn' name='export' value='" . get_lang('exportExcel') . "'/>\n <form>"; } Display::display_footer();
/** * Saves imported data. */ function save_data($users, $course_list, $id_session) { $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); $id_session = intval($id_session); $sendMail = $_POST['sendMail'] ? 1 : 0; // Adding users to the platform. $new_users = array(); foreach ($users as $index => $user) { $user = MySpace::complete_missing_data($user); // coach only will registered users $default_status = '5'; if ($user['create'] == '1') { $user['id'] = UserManager :: create_user($user['FirstName'], $user['LastName'], $default_status, $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], ''); $user['added_at_platform'] = 1; } else { $user['id'] = $user['create']; $user['added_at_platform'] = 0; } $new_users[] = $user; } // Update user list. $users = $new_users; // Inserting users. $super_list = array(); foreach ($course_list as $enreg_course) { $nbr_users = 0; $new_users = array(); $enreg_course = Database::escape_string($enreg_course); foreach ($users as $index => $user) { $userid = intval($user['id']); $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$enreg_course','$userid')"; $course_session = array('course' => $enreg_course, 'added' => 1); //$user['added_at_session'] = $course_session; Database::query($sql); if (Database::affected_rows()) { $nbr_users++; } $new_users[] = $user; } $super_list[] = $new_users; //update the nbr_users field $sql_select = "SELECT COUNT(id_user) as nbUsers FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='$enreg_course'"; $rs = Database::query($sql_select); list($nbr_users) = Database::fetch_array($rs); $sql_update = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'"; Database::query($sql_update); $sql_update = "UPDATE $tbl_session SET nbr_users= '$nbr_users' WHERE id='$id_session'"; Database::query($sql_update); } // We don't delete the users (thoughts while dreaming) //$sql_delete = "DELETE FROM $tbl_session_rel_user WHERE id_session = '$id_session'"; //Database::query($sql_delete); $new_users = array(); foreach ($users as $index => $user) { $userid = $user['id']; $sql_insert = "INSERT IGNORE INTO $tbl_session_rel_user(id_session, id_user) VALUES('$id_session','$userid')"; Database::query($sql_insert); $user['added_at_session'] = 1; $new_users[] = $user; } $users = $new_users; $registered_users = get_lang('FileImported').'<br /> Import file results : <br />'; // Sending emails. $addedto = ''; if ($sendMail) { $i = 0; foreach ($users as $index => $user) { $emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName'); $emailbody = get_lang('Dear').' '.api_get_person_name($user['FirstName'], $user['LastName']).",\n\n".get_lang('YouAreReg')." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : $user[UserName]\n".get_lang('Pass')." : $user[Password]\n\n".get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path(WEB_PATH)." \n\n".get_lang('Problem')."\n\n".get_lang('SignatureFormula').",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email')." : ".api_get_setting('emailAdministrator').""; api_mail_html( api_get_person_name($user['FirstName'], $user['LastName'], null, PERSON_NAME_EMAIL_ADDRESS), $user['Email'], $emailsubject, $emailbody ); if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) { if ($user['added_at_platform'] == 1) { $addedto = get_lang('UserCreatedPlatform'); } else { $addedto = ' '; } if ($user['added_at_session'] == 1) { $addedto .= get_lang('UserInSession'); } $registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />'; } else { $addedto = get_lang('UserNotAdded'); $registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />'; } } } else { $i = 0; foreach ($users as $index => $user) { if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) { if ($user['added_at_platform'] == 1) { $addedto = get_lang('UserCreatedPlatform'); } else { $addedto = ' '; } if ($user['added_at_session'] == 1) { $addedto .= ' '.get_lang('UserInSession'); } $registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />'; } else { $addedto = get_lang('UserNotAdded'); $registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />'; } } } header('Location: course.php?id_session='.$id_session.'&action=show_message&message='.urlencode($registered_users)); exit (); //header('Location: resume_session.php?id_session='.$id_session); }
$users = $results['users']; if (count($errors) == 0) { if (!empty($id_session)) { $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); // Selecting all the courses from the session id requested. $sql = "SELECT course_code FROM $tbl_session_rel_course WHERE id_session='$id_session'"; $result = Database::query($sql); $course_list = array(); while ($row = Database::fetch_array($result)) { $course_list[] = $row['course_code']; } $errors = MySpace::get_user_creator($users, $course_list, $id_session); $users = MySpace::check_all_usernames($users, $course_list, $id_session); if (count($errors) == 0) { MySpace::save_data($users, $course_list, $id_session); } } else { header('Location: course.php?id_session='.$id_session.'&action=error_message&message='.urlencode(get_lang('NoSessionId'))); } } } else { header('Location: course.php?id_session='.$id_session.'&action=error_message&message='.urlencode(get_lang('NoUsersRead'))); } } Display :: display_header($tool_name); if ($_FILES['import_file']['size'] == 0 && $_POST) { Display::display_error_message(get_lang('ThisFieldIsRequired')); }
function main() { $ms_key = CONSUMER_KEY; //we get this from config.MySpace.php $ms_secret = CONSUMER_SECRET; ob_start(); //starts output buffering session_start(); if (@$_GET['f'] == 'start') { // get a request token + secret from MySpace and redirect to the authorization page // $ms = new MySpace($ms_key, $ms_secret); $tok = $ms->getRequestToken("http://localhost/~babar/myspace/myspaceid-sdk/trunk/samples/myspaceid-oauth/index.php?f=callback"); /* if (!isset($tok['oauth_token']) || !is_string($tok['oauth_token']) || !isset($tok['oauth_token_secret']) || !is_string($tok['oauth_token_secret'])) { echo "ERROR! MySpace::getRequestToken() returned an invalid response. Giving up."; exit; } */ $_SESSION['auth_state'] = "start"; $_SESSION['request_token'] = $token = $tok['oauth_token']; $_SESSION['request_secret'] = $tok['oauth_token_secret']; $_SESSION['callback_confirmed'] = $tok['oauth_callback_confirmed']; header("Location: " . $ms->getAuthorizeURL($token)); } else { if (@$_GET['f'] == 'callback') { // the user has authorized us at MySpace, so now we can pick up our access token + secret // if (@$_SESSION['auth_state'] != "start") { echo "Out of sequence."; exit; } $oauth_verifier = @$_GET['oauth_verifier']; if (!isset($oauth_verifier)) { echo "ERROR! MySpace::getAccessToken() returned an invalid response. Giving up."; exit; } // if ($_GET['oauth_token'] != $_SESSION['request_token']) { // echo "Token mismatch."; // exit; // } $ms = new MySpace($ms_key, $ms_secret, $_SESSION['request_token'], $_SESSION['request_secret'], true, $oauth_verifier); $tok = $ms->getAccessToken(); if (!is_string($tok->key) || !is_string($tok->secret)) { error_log("Bad token from MySpace::getAccessToken(): " . var_export($tok, TRUE)); echo "ERROR! MySpace::getAccessToken() returned an invalid response. Giving up."; exit; } $_SESSION['access_token'] = $tok->key; $_SESSION['access_secret'] = $tok->secret; $_SESSION['auth_state'] = "done"; header("Location: " . $_SERVER['SCRIPT_NAME']); } else { if (@$_SESSION['auth_state'] == 'done') { // we have our access token + secret, so now we can actually *use* the api // $ms = new MySpace($ms_key, $ms_secret, $_SESSION['access_token'], $_SESSION['access_secret']); // First get the user id. $userid = $ms->getCurrentUserId(); // Use the userID (fetched in the previous step) to get user's profile, friends and other info $profile_data = $ms->getProfile($userid); displayProfileInfo($profile_data); $friends_data = $ms->getFriends($userid); displayFriendsInfo($friends_data); $albums = $ms->getAlbums($userid); $albumid = $albums->albums[0]->id; $albumInfo = $ms->getAlbumInfo($userid, $albumid); $album = $ms->getAlbum($userid, $albumid); $firstPhoto = $ms->getAlbumPhoto($userid, $albumid, $album->photos[0]->id); displayAlbum($albumInfo, $firstPhoto->imageUri); $friendStatus = $ms->getFriendsStatus($userid); displayObject($friendStatus, '$friendStatus'); $indicators = $ms->getIndicators($userid); displayObject($indicators, '$indicators'); $statusHistory = $ms->getStatusHistory($userid); displayObject($statusHistory, '$statusHistory'); //$ms->updateStatus($userid, 'Updating from php sdk'); // Test put and get app data $ms->putAppData($userid, array('location' => 'usa', 'interests' => 'tennis, golf', 'age' => '21')); $appData = $ms->getAppData($userid, 'interests;location'); displayObject($appData, '$appData for interests and location only'); $appData = $ms->getAppData($userid); displayObject($appData, '$appData for all parameters'); // Test clear app data $ms->clearAppData($userid, 'location;age'); sleep(3); $appData = $ms->getAppData($userid); displayObject($appData, '$appData after clearing'); // Test get friends' app data $appData = $ms->getUserFriendsAppData($userid); displayObject($appData, '$appData for friends'); // Test Poco get user $pocoPerson = $ms->getPersonPoco('movies'); displayObject($pocoPerson, '$pocoPerson'); // Test Poco get friends $pocoFriends = $ms->getFriendsPoco(); displayObject($pocoFriends, '$pocoPerson'); } else { // not authenticated yet, so give a link to use to start authentication. ?> <p><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?> ?f=start">Click here to authenticate with MySpace</a></p><?php } } } }
public static function getMySpaceCookiePath() { $tmp_dir = getenv("TEMP"); if (empty($tmp_dir)) { $tmp_dir = "/tmp"; } self::$cookiePath = kFile::fixPath($tmp_dir . DIRECTORY_SEPARATOR . "kaltura/myspace/cookies"); return self::$cookiePath; }
function run() { loginRequired(); $userid = $_SESSION['userID']; $ms = new MySpace(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['access_token_key'], $_SESSION['access_token_secret']); // Use the userID (fetched in the previous step) to get user's profile, friends and other info $profile_data = $ms->getProfile($userid); $friends_data = $ms->getFriends($userid); $activities_data = $ms->getActivities_ATOM($userid); $friendsActivities_data = $ms->getFriendsActivities_ATOM($userid); //43508565 $test2 = ''; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>MySpaceID Hybrid Example <?php echo isset($profile_data) ? $profile_data->basicprofile->name : 'not logged in'; ?> profile</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" type="text/css" href="static/base.css"> <!-- YUI Combo CSS + JS files: --> <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.6.0/build/tabview/assets/skins/sam/tabview.css"> <script type="text/javascript" src="http://yui.yahooapis.com/combo?2.6.0/build/yahoo-dom-event/yahoo-dom-event.js&2.6.0/build/imageloader/imageloader-min.js&2.6.0/build/element/element-beta-min.js&2.6.0/build/tabview/tabview-min.js"></script> <style> .activity{ background:#abc; border:1px #fff solid; } </style> </head> <body class="yui-skin-sam"> <h2>profile page</h2> <?php if (isset($profile_data)) { echo <<<EOL \t\t<div id="MySpaceTabs" class="yui-navset"> \t\t <ul class="yui-nav"> \t\t <li id='profileTab' class="selected"><a href="#tab1"><em>Profile</em></a></li> \t\t <li id='friendsTab'><a href="#tab2"><em>Friends</em></a></li> \t\t <li id='activitiesTab'><a href="#tab3"><em>Activities</em></a></li> \t\t </ul> \t\t <div class="yui-content"> \t\t <div id='profileTabContent'> \t\t \t<p><img src="{$profile_data->basicprofile->image}" /></p> \t\t <p>Profile URL : <a href="{$profile_data->basicprofile->webUri}"> {$profile_data->basicprofile->webUri}</a><p> \t\t <p>Name: <strong> {$profile_data->basicprofile->name} </strong> </p> \t\t <p>Gender: <strong> {$profile_data->gender} </strong> </p> \t\t <p>Age: <strong> {$profile_data->age} </strong> </p> \t\t <p>Marital Status: <strong> {$profile_data->maritalstatus} </strong> </p> \t\t <p>City: <strong> {$profile_data->city} </strong> </p> \t\t <p>Postal Code: <strong> {$profile_data->postalcode} </strong> </p> \t\t <p>Region: <strong> {$profile_data->region} </strong> </p> \t\t <p>Country: <strong> {$profile_data->country} </strong> </p> \t\t </div> EOL; } ?> <?php if (isset($friends_data)) { // Build up the HTML that represent the content that goes into the // Friends Tab // Then insert the content block via $friendsContent below // $onlineFriends_data = $ms->getFriends($userid, null, null, 'online', 'online'); $friendsContent = ""; foreach ($friends_data->Friends as $friend) { $friendsContent .= "<a href='{$friend->webUri}'>"; $friendsContent .= "<img id='{$friend->name}' title='{$friend->name}' border='0'></a>"; } echo <<<EOL \t\t\t\t<div id='friendsTabContent'> \t\t\t\t {$friendsContent} \t\t </div> EOL; } ?> <?php if (isset($friendsActivities_data)) { // Build up the HTML that represent the content that goes into the // Friends Tab // Then insert the content block via $friendsContent below // echo "<div id='activitiesTabContent'>"; $activitiesContent = $friendsActivities_data; //$title = mb_convert_encoding ($xml->entry[32]->title[0],'UTF-8',"UTF-8, ASCII, ISO-8859-1, EUC-JP, SJIS, JIS") ; print '<span class="entry_title">'; print $title; //$xml->entry[32]->title[0]; print '</span>'; print '<br/><span><strong>RAW:: </strong>' . mb_convert_encoding('???? ??? ��� ??????? is now friends with Sue Cho', 'utf-8', "UTF-8, ASCII, ISO-8859-1, EUC-JP, SJIS, JIS") . '</span>'; print '<br /><span class="entry_title"><strong>' . mb_detect_encoding($title . 'a', " UTF-8, ASCII, ISO-8859-1, UTF-16, UTF-32", true) . '</strong></span>'; print '<br /><span class="entry_title"><strong>' . mb_http_output() . '</strong></span>'; $xml = $friendsActivities_data; $xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); $xml->registerXPathNamespace('activity', 'http://activitystrea.ms/schema/1.0/'); $xml->registerXPathNamespace('xCal', 'urn:ietf:params:xml:ns:xcal'); $xml->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); $songlist_xml = $xml->xpath('atom:entry/atom:category[@label="SongUpload" or @label="ProfileSongAdd"]/ancestor::atom:entry'); //$songlist_xml = $xml->xpath('atom:entry/atom:category[@label="SongUpload" or @label="ProfileSongAdd"]/..'); $band_data = $ms->getFriendsActivities_ATOM($userid, null, null, 'PersonalBandShowUpdate'); //43508565 $band_data->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); $band_data->registerXPathNamespace('activity', 'http://activitystrea.ms/schema/1.0/'); $band_data->registerXPathNamespace('xCal', 'urn:ietf:params:xml:ns:xcal'); //$bandShows_xml = $band_data->xpath('atom:entry/atom:category[@label="PersonalBandShowUpdate"]/..'); $bandShows_xml = $band_data->xpath('//xCal:location/ancestor::atom:entry'); foreach ($bandShows_xml as $bandShow) { $bandShow_activity = $bandShow->xpath('activity:object'); $bandShow_activity = $bandShow_activity[0]; $bandShow_title = (string) $bandShow_activity->title; $bandShow_link = (string) $bandShow_activity->link['href']; $bandShow_summary = (string) $bandShow_activity->vevent->summary; $bandShow_location = (string) $bandShow_activity->vevent->location; //$bandShow_dateStart = new DateTime( (string)$bandShow_activity->vevent-dsStart); //, 'Y-m-d\TH:i:s\Z', '%Y-%m-%dTH:%M:%SZ'); //2009-03-21T03:00:00Z $break = ''; } echo "<h1><span class='display-name'>{$profile_data->basicprofile->name}'s Activites</span></h1>"; echo '<ul id="activities">'; foreach ($songlist_xml as $song_entry) { echo '<li>' . $song_entry->content->asXML() . '</li>'; } echo '</ul>'; foreach ($xml->xpath('atom:entry[category/@label="BlogAdd"]') as $entry) { $children = ''; $content = ''; echo "\n<ul class='activities'>\n"; switch ((string) $entry->category['label'][0]) { case 'EventAttending': echo '<li class="activity">'; $entry->registerXPathNamespace('atom', 'http://www.w3.org/2005/Atom'); $iconlink = $entry->xpath('atom:id'); $iconlink = $entry->xpath('atom:link[@rel="icon" and @href]'); print "<img src='" . $iconlink[0]['href'] . "' />"; $children = $entry->content->div->children(); foreach ($children as $child) { $content = $child->asXML(); echo "\n" . $content . ""; } echo '</li><!-- class="activity" -->'; break; case 'EventPosting': echo '<li class="activity">'; $children = $entry->content->div->children(); foreach ($children as $child) { $content = $child->asXML(); echo "\n" . $content . ""; } echo '</li><!-- class="activity" -->'; break; case 'ProfileSongAdd': echo '<li class="activity">'; $children = $entry->content->div->children(); foreach ($children as $child) { $content = $child->asXML(); echo "\n" . $content . ""; } echo '</li><!-- class="activity" -->'; break; case 'FriendAdd': break; case 'FriendCategoryAdd': break; case 'ForumPosted': break; case 'JoinedGroup': break; case 'ForumTopicReply': break; case 'ProfileVideoUpdate': break; case 'FavoriteVideoAdd': break; case 'PhotoAdd': break; case 'MobilePhotoUpload': break; case 'PhotoTagged': break; case 'BlogAdd': break; default: echo '<li class="activity">'; $children = $entry->content->div->children(); foreach ($children as $child) { $content = $child->asXML(); echo "\n" . $content . ""; } echo '</li><!-- class="activity" -->'; } echo "\n</ul>"; } echo "</div>"; } ?> <?php if (isset($friends_data)) { // We build up a string that represents the image loader code // for each of the friend images. // We then insert that string below by referencing $imageLoaderCode // $imageLoaderCode = ""; foreach ($friends_data->Friends as $friend) { $imageLoaderCode .= "tabTwoImageGroup.registerSrcImage('{$friend->name}', '{$friend->image}');"; } echo <<<EOL </div> \t\t</div> \t\t<script type="text/javascript"> \t\t\tvar myTabs = new YAHOO.widget.TabView("MySpaceTabs"); \t\t\t// Friends Tab Image Loader \t\t\tvar tabTwoImageGroup = new YAHOO.util.ImageLoader.group('friendsTab', 'mouseover'); \t\t\t{$imageLoaderCode} \t\t\ttabTwoImageGroup.addTrigger('friendsTab', 'focus'); \t\t\ttabTwoImageGroup.name = 'tab_two_group'; \t\t</script> EOL; } ?> </body> </html> <?php }
function connect() { $ms_key = CONSUMER_KEY; //we get this from config.MySpace.php $ms_secret = CONSUMER_SECRET; if (!empty($this->params['url']['f'])) { if ($this->params['url']['f'] == 'start') { // get a request token + secret from MySpace and redirect to the authorization page $ms = new MySpace($ms_key, $ms_secret); $host = $_SERVER['HTTP_HOST'] . $this->base; $tok = $ms->getRequestToken("http://{$host}/mss/connect/?f=callback"); if (!isset($tok['oauth_token']) || !is_string($tok['oauth_token']) || !isset($tok['oauth_token_secret']) || !is_string($tok['oauth_token_secret'])) { $this->Session->setFlash('Invalid response.'); $this->redirect('/band/manage/'); exit; } $this->Session->write('auth_state', 'start'); $this->Session->write('request_token', $tok['oauth_token']); $this->Session->write('request_secret', $tok['oauth_token_secret']); $this->Session->write('callback_confirmed', $tok['oauth_callback_confirmed']); header("Location: " . $ms->getAuthorizeURL($tok['oauth_token'])); exit; } else { if (@$_GET['f'] == 'callback') { // the user has authorized us at MySpace, so now we can pick up our access token + secret if ($this->Session->check('auth_state')) { if ($this->Session->read('auth_state') != 'start') { $this->Session->setFlash('Invalid call.'); $this->redirect('/band/manage/'); exit; } } // if($this->Session->check('auth_state')) // the user has authorized us at MySpace, so now we can pick up our access token + secret if (!empty($this->params['url']['oauth_problem'])) { if ($this->params['url']['oauth_problem'] == 'user_refused') { $this->redirect('/band/manage/'); exit; } else { $this->Session->setFlash('Authorization problem.'); $this->redirect('/band/manage/'); exit; } } // if($this->Session->check('auth_state')) /* Get Band Id from Session or Cookie */ if ($this->Session->check('band_id')) { $band_id = $this->Session->read('band_id'); } elseif ($this->Cookie->valid('bandid')) { $band = $this->Cookie->read('bandid'); $band_id = $band['bandid']; // band_id value get from cookie } else { $this->Session->setFlash('Please select a band.'); $this->redirect('/band/index/'); exit; } $oauth_verifier = $this->params['url']['oauth_verifier']; if (!isset($oauth_verifier)) { $this->Session->setFlash('Invalid response.'); $this->redirect('/band/manage/'); exit; } $ms = new MySpace($ms_key, $ms_secret, $this->Session->read('request_token'), $this->Session->read('request_secret'), true, $oauth_verifier); $tok = $ms->getAccessToken(); if (!is_string($tok->key) || !is_string($tok->secret)) { error_log("Bad token from MySpace::getAccessToken(): " . var_export($tok, TRUE)); $this->Session->setFlash('Invalid response.'); $this->redirect('/band/manage/'); exit; } $ms = new MySpace($ms_key, $ms_secret, $tok->key, $tok->secret); $webUri = $ms->getCurrentUserId(); // get user id from webUri $user_id = substr($webUri, strrpos($webUri, "/") + 1, strlen($webUri)); $result = $this->Msslogin->find(array('user_id' => $user_id, 'band_id' => $band_id)); if ($result) { $result['Msslogin']['access_token'] = $tok->key; $result['Msslogin']['access_secret'] = $tok->secret; $result['Msslogin']['oauth_token'] = $this->Session->read('request_token'); $result['Msslogin']['oauth_token_secret'] = $this->Session->read('request_secret'); $result['Msslogin']['link'] = '1'; $this->Msslogin->save($result); $this->Session->setFlash('MySpace update status permission allowed.'); $band = $this->Cookie->read('flag'); // myspace called from wizard or setting manage $flag = $band["flag"]; if ($flag == 'b') { $this->redirect('/band/myspace/'); } else { $this->redirect('/band/manage/'); } exit; } else { // return to band manager or band wizard page $this->addprofile($user_id, $tok->key, $tok->secret, $band_id); } } } } else { $this->Session->setFlash('Invalid response.'); $this->redirect('/band/manage/'); exit; } $this->Session->setFlash('Invalid response.'); $this->redirect('/band/manage/'); exit; }
$req = OAuthRequest::from_request($method, $http_url); $req->del_parameter('oauth_signature'); //print "<br>Req = " . $req; $sigMethod = new OAuthSignatureMethod_HMAC_SHA1(); $consumer = new OAuthConsumer($ms_key, $ms_secret); $signature = $sigMethod->build_signature($req, $consumer); print "<br>Base string = " . $req . base_string; print "<br>Built Signature = " . $signature . ""; print "<br>Passed in Signature = " . $_GET['oauth_signature'] . "<br>"; if (strcmp($_GET['oauth_signature'], $signature) != 0) { print "Signatures don't match! Exiting.<br>"; } else { print "Signatures match!"; // Send notification $userId = @$_GET['opensocial_viewer_id']; $ms = new MySpace($ms_key, $ms_secret, null, null, false); $templateParameters = array('content' => 'Test notification content from php sdk', 'button0_surface' => 'canvas', 'button0_label' => 'Go To App Canvas', 'button1_surface' => 'appProfile', 'button1_label' => 'Go To App Profile'); $rc = $ms->sendNotification('129910', '454304609,28568917', $templateParameters, 'http://api.myspace.com/v1/users/296768296'); echo '<br><br>sendNotification returned ' . $rc; $profileInfo = $ms->getProfile($userId); displayProfileInfo($profileInfo); $albumInfo = $ms->getAlbumInfo($userId, "817520"); displayAlbumInfo($albumInfo); $appData = $ms->getGlobalAppData(); displayObject($appData, "appData"); $ms->putGlobalAppData(array('animal' => 'giraffe', 'plant' => 'rose', 'mineral' => 'sandstone')); sleep(3); $appData = $ms->getGlobalAppData(); displayObject($appData, "appData"); $appData = $ms->getGlobalAppData('animal;plant'); displayObject($appData, "appData for only animal and plant");
<?php require "MySpace.class.php"; $myspace = new MySpace(); $myspace->getMusic();