The following diagram illustrates the relationships between the classes belonging to the Social namespace.
An SnsGateway defines the interfaces to external social networking services. In version 1.0, the supported service providers are Twitter and Facebook, and MySpace.
Authentication is needed to access the service providers. See the SnsAuthenticator
. In version 1.0, the OAuth authentication is available and it is used for Twitter and MySpace. The Facebook Connect authentication is also available. SnsGateway needs SnsAuthResult which contains the consumer key, consumer secret, token key and token secret as a result of authentication described on OAuth specification. More information on the OAuth specification can be found at http://www.oauth.net. The SnsAuthResult can be obtained using Osp::Social::Services::SnsAuthenticator. After the authentication on the service provider, the SnsGateway::AddAuthResult() method has to be called to successfully call other methods of SnsGateway. SnsGateway uses the value of SnsAuthResult to access the user's resource on the specific service provider.
The authentication result will be stored in the application folder of the device when SnsGateway::AddAuthResult() is called.
Therefore, the authentication result need not be added every time the user uses the application.
When the authentication result is stored, the user information can be accessed without adding the authentication result after creating the instance of SnsGateway.
The session resumes based on the previously added authentication result.
The session cannot be resumed if the session of the service provider has expired or if the user has revoked the authentication.
In these cases, you may receive an error message such as "Unauthorized".
To remove the stored authentication result of a specific service provider, call SnsGateway::RemoveAuthResult().
In version 1.0, following feature are supported:
Feature | MySpace | ||
Get my buddy list | O(following) | O | O |
Get user status text | O | O | O |
Set my status text | O | O | O |
Get user profile | O | O | O |
Get activities | O(tweets) | O | O |
Get photos by photo ID | - | O | - |
Get photos of a specific user | - | - | O(Logged-in user's only) |
Get photo album list of a specific user | - | O | O |
Get photos in a specific album | - | O | O |
Upload photo | - | O | O |
In version 1.2, the following feature is added:
Feature | MySpace | ||
Publish a post | - | O | - |
You can access the methods of a service provider that are not supported in this SnsGateway even if that method requires authentication. The token key and the token secret of SnsAuthResult is also available on the specific service provider.
serviceProvider
of each method has to be small character, like "twitter", "facebook", and "myspaceid". seviceProvider
has to be "myspaceid". See the code snippets for information on how to use the SnsGateway methods.
Osp::Social::Services::SnsGateway::GetMyBuddies()
Osp::Social::Services::SnsGateway::UpdateMyStatusText()
Osp::Social::Services::SnsGateway::GetPhotoAlbums()
Osp::Social::Services::SnsGateway::GetPhotosInAlbum()
Osp::Social::Services::SnsGateway::GetPhotosByUser()
Osp::Social::Services::SnsGateway::UploadPhoto()
Osp::Social::Services::SnsGateway::SnsGateway | ( | void | ) |
This is the default constructor for this class.
This creates an uninitialized instance of SnsGateway.
virtual Osp::Social::Services::SnsGateway::~SnsGateway | ( | void | ) | [virtual] |
This is the destructor for this class.
result Osp::Social::Services::SnsGateway::AddAuthResult | ( | const Osp::Social::Services::SnsAuthResult & | snsAuthResult | ) |
Adds the authentication result of the specific service provider.
[in] | snsAuthResult | The authentication result |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_INVALID_ARG | The specified input parameter is invalid. |
E_OUT_OF_MEMORY | The memory is insufficient. |
result Osp::Social::Services::SnsGateway::Construct | ( | const ISnsGatewayListener & | gatewayListener, |
const ISnsContentListener * | pContentListener, | ||
const ISnsPeopleListener * | pPeopleListener, | ||
const ISnsActivityListener * | pActivityListener, | ||
const ISnsPostListener * | pPostListener | ||
) |
Initializes this instance of SnsGateway with the specified listeners.
[in] | gatewayListener | The event listener This listener is mandatory as it receives the response of IsLoggedIn(). |
[in] | pContentListener | The listener for receiving the response of content-related methods from the server This listener is optional as it receives the response of a request related to a photo. |
[in] | pPeopleListener | The listener for receiving the response of people-related methods from the server This listener is optional as it receives the response of a request related to a buddy, profile, and status text. |
[in] | pActivityListener | The listener for receiving the response of activity-related methods from the server This listener is optional as it receives the response of a request related to an activity. |
[in] | pPostListener | The listener for receiving the response of post-related methods from the server This listener is optional as it receives the response of a request related to a post. |
E_SUCCESS | The method is successful. |
E_OUT_OF_MEMORY | The memory is insufficient. |
E_INVALID_STATE | This instance has already been constructed. |
result Osp::Social::Services::SnsGateway::Construct | ( | const ISnsGatewayListener & | gatewayListener, |
const ISnsContentListener * | pContentListener, | ||
const ISnsPeopleListener * | pPeopleListener, | ||
const ISnsActivityListener * | pActivityListener | ||
) |
Initializes this instance of SnsGateway with the specified listeners.
[in] | gatewayListener | The event listener This listener is mandatory as it receives the response of IsLoggedIn(). |
[in] | pContentListener | The listener for receiving the response of content-related methods from the server This listener is optional as it receives the response of a request related to a photo. |
[in] | pPeopleListener | The listener for receiving the response of people-related methods from the server This listener is optional as it receives the response of a request related to a buddy, profile, and status text. |
[in] | pActivityListener | The listener for receiving the response of activity-related methods from the server This listener is optional as it receives the response of a request related to an activity. |
E_SUCCESS | The method is successful. |
E_OUT_OF_MEMORY | The memory is insufficient. |
E_INVALID_STATE | This instance has already been constructed. |
result Osp::Social::Services::SnsGateway::GetActivities | ( | const Osp::Base::String & | serviceProvider, |
const Osp::Base::String * | pActivityOwner, | ||
const SnsPagingParam & | pagingParam, | ||
RequestId & | reqId | ||
) |
Gets the activities of the users specified by the owner for a specific service provider.
The owner can be "All" or the specific snsUserId.
[in] | serviceProvider | The service provider |
[in] | pActivityOwner | The owner of activity The parameter is set to null to get the activities of the logged-in user. The parameter is set to all if you want to get the activities of the logged-in user and logged-in user's friends. The parameter is set to snsUserId if you want to get the activity of some user. |
[in] | pagingParam | The SnsPagingParam instance that indicates the page number and maximum count of result items in the page |
[out] | reqId | The request ID |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet, or the sign-in is not completed. |
E_INVALID_ARG | Either of the following conditions has occurred:
|
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_OUT_OF_MEMORY | The memory is insufficient. |
result Osp::Social::Services::SnsGateway::GetMyBuddies | ( | const Osp::Base::String & | serviceProvider, |
SnsPagingParam & | pagingParam, | ||
RequestId & | reqId | ||
) |
Gets the buddies of the signed-in user from the specified service provider.
[in] | serviceProvider | The service provider |
[in] | pagingParam | The SnsPagingParam instance that indicates the page number and maximum number of result items on the page |
[out] | reqId | The request ID |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet, or the sign-in is not completed. |
E_INVALID_ARG | The specified serviceProvider is an empty string, or a proper listener is not registered. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_OUT_OF_MEMORY | The memory is insufficient. |
The following example demonstrates how to use this method:
void MyClass::GetBuddies(void) { result r = E_SUCCESS; RequestId reqId; String providerName = L"twitter"; SnsPagingParam pagingParam(5); r = pSnsGateway->GetMyBuddies(providerName, pagingParam, reqId); } void MySnsPeopleListener::OnMySnsBuddiesReceivedN(RequestId reqId, Osp::Base::Collection::IList* pBuddyProfileList, bool hasNext, SnsPagingParam& pagingParam, result r, const Osp::Base::String& errorCode, const Osp::Base::String& errorMsg) { IEnumerator* pEnum = null; SnsProfile* pProfile = null; String buddyName; if (r != E_SUCCESS) { // Do something for an error. } if (pBuddyProfileList) { // Do something. pEnum = pBuddyProfileList->GetEnumeratorN(); while (true) { if (pEnum->MoveNext() == E_OUT_OF_RANGE) { break; } pProfile = (SnsProfile*)pEnum->GetCurrent(); if (pProfile == null) { // Do something for an error. } r = pProfile->GetValue(SNS_PROFILE_PID_USER_NAME, buddyName); // Check result. // Do something more. } delete pEnum; } // Deletes the list and deallocates the memory pBuddyProfileList->RemoveAll(true); delete pBuddyProfileList; }
result Osp::Social::Services::SnsGateway::GetPhoto | ( | const Osp::Base::String & | serviceProvider, |
const Osp::Base::String * | pPhotoOwnerId, | ||
const Osp::Base::String & | photoId, | ||
RequestId & | reqId | ||
) |
Gets the photo by specific photoId.
[in] | serviceProvider | The service provider |
[in] | pPhotoOwnerId | The user ID who owns the photo, else set to null if the photo is that of the logged-in user |
[in] | photoId | The photo ID to be got |
[out] | reqId | The ID of the request |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet, or the sign-in is not completed. |
E_INVALID_ARG | The specified serviceProvider is an empty string, or a proper listener is not registered. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_OUT_OF_MEMORY | The memory is insufficient. |
result Osp::Social::Services::SnsGateway::GetPhotoAlbums | ( | const Osp::Base::String & | serviceProvider, |
const Osp::Base::String * | pAlbumOwnerId, | ||
SnsPagingParam & | pagingParam, | ||
RequestId & | reqId | ||
) |
Gets a list of the albums of the user from the specified service provider.
[in] | serviceProvider | The service provider |
[in] | pAlbumOwnerId | The ID of the user whose album is required, set to null if the album required is of the signed-in user |
[in] | pagingParam | The SnsPagingParam instance that indicates the page number and the maximum number of result items on a page |
[out] | reqId | The request ID |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet, or the sign-in is not completed. |
E_INVALID_ARG | The specified serviceProvider or albumId is an empty string, or a proper listener is not registered. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_OUT_OF_MEMORY | The memory is insufficient. |
The following example demonstrates how to use this method:
void MyClass::GetMyPhotoAlbums(void) { result r = E_SUCCESS; RequestId reqId; SnsPagingParam pagingParam(5); r = pSnsGateway->GetPhotoAlbums(L"facebook", null, pagingParam, reqId); } void MyClass::GetBuddyPhotoAlbums(SnsProfile* pBuddyProfile) { result r = E_SUCCESS; RequestId reqId; String snsUserId = pBuddyProfile->GetSnsUserId(); String serviceProvider = pBuddyProfile->GetServiceProvider(); SnsPagingParam pagingParam(5); r = pSnsGateway->GetPhotoAlbums(serviceProvider, &snsUserId, pagingParam, reqId); }
result Osp::Social::Services::SnsGateway::GetPhotosByUser | ( | const Osp::Base::String & | serviceProvider, |
const Osp::Base::String * | pSnsUserId, | ||
SnsPagingParam & | pagingParam, | ||
RequestId & | reqId | ||
) |
Gets the photos belonging to the user specified by snsUserId.
[in] | serviceProvider | The service provider |
[in] | pSnsUserId | The ID of the user who owns the photos, else set to null if the photos are owned by the signed-in user |
[in] | pagingParam | The SnsPagingParam instance that indicates the page number and maximum number of result items on the page |
[out] | reqId | The request ID |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet, or the sign-in is not completed. |
E_INVALID_ARG | The specified serviceProvider is an empty string, or a proper listener is not registered. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_OUT_OF_MEMORY | The memory is insufficient. |
The following example demonstrates how to use this method:
void MyClass::GetBuddyPhotos(SnsProfile* pSnsBuddyProfile) { result r = E_SUCCESS; RequestId reqId; String providerName = pSnsBuddyProfile->GetServiceProvider(); String buddyId = pSnsBuddyProfile->GetSnsUserId(); SnsPagingParam pagingParam(5); r = pSnsGateway->GetPhotosByUser(providerName, &buddyId, pagingParam, reqId); } void MySnsContentListener::OnSnsPhotosByUserReceivedN(RequestId reqId, Osp::Base::Collection::IList* pPhotoList, bool hasNext, SnsPagingParam& pagingParam, result r, const Osp::Base::String& errorCode, const Osp::Base::String& errorMsg) { IEnumerator* pEnum = null; SnsPhotoInfo* pPhoto = null; String title; if (r != E_SUCCESS) { // Do something for an error. } if (pPhotoList) { // Do something (show photo list or get image). pEnum = pPhotoList->GetEnumeratorN(); while (true) { if (pEnum->MoveNext() == E_OUT_OF_RANGE) { break; } pPhoto = (SnsPhotoInfo*)pEnum->GetCurrent(); if (pPhoto == null) { // Do something for an error. } r = pPhoto->GetValue(SNS_PHOTO_PID_TITLE, title); // Check result. // Do something more. } delete pEnum; } // Deletes the list and deallocates the memory. pPhotoList->RemoveAll(true); delete pPhotoList; }
result Osp::Social::Services::SnsGateway::GetPhotosInAlbum | ( | const Osp::Base::String & | serviceProvider, |
const Osp::Base::String * | pAlbumOwnerId, | ||
const Osp::Base::String & | albumId, | ||
SnsPagingParam & | pagingParam, | ||
RequestId & | reqId | ||
) |
Gets the photos in the specified album of the user identified by the specified snsUserId.
[in] | serviceProvider | The service provider |
[in] | pAlbumOwnerId | The ID of the user owning the photo album, else set to null if the album belongs to the signed-in user |
[in] | albumId | The album ID |
[in] | pagingParam | The SnsPagingParam instance that indicates the page number and the maximum number of result items on a page |
[out] | reqId | The request ID |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet, or the sign-in is not completed. |
E_INVALID_ARG | The specified serviceProvider or albumId is an empty string, or a proper listener is not registered. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_OUT_OF_MEMORY | The memory is insufficient. |
The following example demonstrates how to use this method:
void MyClass::GetBuddyPhotosInAlbum(SnsAlbumInfo *pAlbum) { result r = E_SUCCESS; RequestId reqId; String snsUserId; String albumId; String serviceProvider; SnsPagingParam pagingParam(5); r = pAlbum->GetValue(SNS_ALBUM_PID_OWNER_ID, snsUserId); albumId = pAlbum->GetAlbumId(); serviceProvider = pAlbum->GetServiceProvider(); r = pSnsGateway->GetPhotosInAlbum(serviceProvider, &snsUserId, albumId, pagingParam, reqId); }
result Osp::Social::Services::SnsGateway::GetProfile | ( | const Osp::Base::String & | serviceProvider, |
const Osp::Base::String * | pSnsUserId, | ||
RequestId & | reqId | ||
) |
Gets the profile of the users specified by the snsUserId
for a specific service provider.
[in] | serviceProvider | The service provider |
[in] | pSnsUserId | The Sns user ID, else set to null if the profile is of the logged-in user |
[out] | reqId | The ID of the request |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet, or the sign-in is not completed. |
E_INVALID_ARG | The specified serviceProvider is an empty string, or a proper listener is not registered. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_OUT_OF_MEMORY | The memory is insufficient. |
result Osp::Social::Services::SnsGateway::GetStatusText | ( | const Osp::Base::String & | serviceProvider, |
const Osp::Base::String * | pSnsUserId, | ||
RequestId & | reqId | ||
) |
Gets the status text of the specified user on the specified service provider.
[in] | serviceProvider | The service provider |
[in] | pSnsUserId | The snsUserId of the user, else set to null if the status of the sign-in user is required |
[out] | reqId | The request ID |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet, or the sign-in is not completed. |
E_INVALID_ARG | The specified serviceProvider is an empty string, or a proper listener is not registered. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_OUT_OF_MEMORY | The memory is insufficient. |
result Osp::Social::Services::SnsGateway::IsLoggedIn | ( | const Osp::Base::String & | serviceProvider, |
RequestId & | reqId | ||
) |
Gets the sign-in status for the specified service provider.
This method checks whether the added authentication result is currently valid or not.
If ISnsGatewayListener::OnSnsLoggedInStatusReceived() returns false
, it means that the user authentication is needed for the specific service provider.
[in] | serviceProvider | The service provider |
[out] | reqId | The request ID |
E_SUCCESS | The method is successful. |
E_INVALID_ARG | The specified serviceProvider is an empty string. |
E_INVALID_STATE | This instance has not been constructed as yet, or the sign-in is not completed. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_OUT_OF_MEMORY | The memory is insufficient. |
result Osp::Social::Services::SnsGateway::PublishPost | ( | const Osp::Base::String & | serviceProvider, |
const SnsPostInfo & | postInfo, | ||
RequestId & | reqId | ||
) |
Publishes the post to the specified service provider.
[in] | serviceProvider | The service provider |
[in] | postInfo | The SnsPostInfo instance that contains the information of the post to be published |
[out] | reqId | The request ID |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet or, the sign-in process has not finished. |
E_INVALID_ARG | The specified serviceProvider is an empty string, or a proper listener is not registered. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_OUT_OF_MEMORY | The memory is insufficient. |
result Osp::Social::Services::SnsGateway::RemoveAuthResult | ( | const Osp::Base::String & | serviceProvider | ) |
Removes the authentication result of the service provider.
The token key and token secret of the specific service provider are not expired.
[in] | serviceProvider | The service provider |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_INVALID_ARG | The specified serviceProvider is an empty string. |
E_OUT_OF_MEMORY | The memory is insufficient. |
result Osp::Social::Services::SnsGateway::UpdateMyStatusText | ( | const Osp::Base::String & | serviceProvider, |
const Osp::Base::String & | statusText, | ||
RequestId & | reqId | ||
) |
Sets the status text to the specified service provider.
[in] | serviceProvider | The service provider |
[in] | statusText | The status text to update |
[out] | reqId | The request ID |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet, or the sign-in is not completed. |
E_INVALID_ARG | The specified serviceProvider or statusText is an empty string, or a proper listener is not registered. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_OUT_OF_MEMORY | The memory is insufficient. |
The following example demonstrates how to use this method:
result Osp::Social::Services::SnsGateway::UploadPhoto | ( | const Osp::Base::String & | serviceProvider, |
const Osp::Base::String * | pAlbumId, | ||
const SnsUploadContentInfo & | contentInfo, | ||
RequestId & | reqId | ||
) |
Uploads a photo to a specific service provider.
The content type and the source file path must be set in SnsUploadContentInfo instance.
The album ID is optional. If you want to upload a photo to the specific user created album of serviceProvider
, the pAlbumId
has to be set. If you want to upload a photo to the common album, the albumId
should be set to null
.
[in] | serviceProvider | The service provider |
[in] | pAlbumId | The destination album ID |
[in] | contentInfo | The information of the content to be uploaded |
[out] | reqId | The ID of the request |
E_SUCCESS | The method is successful. |
E_INVALID_STATE | This instance has not been constructed as yet, or the sign-in is not completed. |
E_INVALID_ARG | Either of the following conditions has occurred:
|
E_FILE_NOT_FOUND | The source file is not found. |
E_PRIVILEGE_DENIED | The application does not have the privilege to call this method. |
E_OUT_OF_MEMORY | The memory is insufficient. |
The following example demonstrates how to use this method:
void MyClass::UploadPhotoToProvider(String filePath) { result r = E_SUCCESS; RequestId reqId; String serviceProvider = L"facebook"; SnsUploadContentInfo* pContent = new SnsUploadContentInfo(SNS_UPLOAD_CONTENT_PHOTO, filePath); pContent->SetValue(SNS_CONTENT_PID_TITLE, L"trip"); r = pSnsGateway->UploadPhoto(serviceProvider, null, *pContent, reqId); delete pContent; }