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"); }
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'; }
function updateStatus() { if ($this->data) { if (!empty($this->data['Dashboard']['mss'])) { $mmm_id = $this->Session->read('id'); $band_id = $this->data['Dashboard']['bandid']; $result = $this->Msslogin->find(array('mmm_id' => $mmm_id, 'band_id' => $band_id, 'status' => 1, 'link' => '1', array('not' => array('access_token' => null)), array('not' => array('access_secret' => null)))); if ($result) { $ms_key = CONSUMER_KEY; //we get this from config.MySpace.php $ms_secret = CONSUMER_SECRET; $token = $result['Msslogin']['access_token']; $secret = $result['Msslogin']['access_secret']; //$oauth_verifier = $result['Msslogin']['oauth_verifier']; /* $ms = new MySpace($ms_key, $ms_secret, $token, $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 "Invalid response."; exit; } */ $text = $this->data['Dashboard']['status']; $ms = new MySpace($ms_key, $ms_secret, $token, $secret); $userid = $ms->getCurrentUserIds(); $ms->updateStatus($userid, $text); echo "MySpace status updated succesfully"; exit; } else { echo "We need your permission to publish a status update to your MySpace profile. Go to the settings page and click Add new MySpace profile link."; exit; } } } exit; }