">mixi Developer Center (mDC)

mixi Connect

mixi Connect (English) » mixi Graph API » mixi API SDK for iOS » Using APIs

Using APIs

There are several methods to access the API. The representative method is Mixi#sendRequest:delegate: . By using this method, you are able to call various API in a unified manner.

A simple example of the sendRequest:delegate: method to call an API will be introduced here. For the details of each API such as the meaning of parameters and the return value for the APIs, please see the reference attached to the SDK.

An API is called by giving the endpoint as a parameter to the MixiRequest constructor method and Mixi#sendRequest:delegate:: with the MixiRequest instance and an instance of MixiDelegate. Verify whether the authorization is completed before calling the API. If unauthorized, you must authorize first. If authorization fails, the mixi official app may not be installed or may not be the latest version. You need to download the mixi official app from the AppStore.

if ([mixi isAuthorized]) {
    MixiRequest *request = [MixiRequest requestWithEndpoint:@"/people/@me/@friends"];
    [mixi sendRequest:request delegate:mixiDelegate];
}
else if (![mixi authorizeForPermission:@"r_profile"]) {
    MixiWebViewController *vc = MixiUtilDownloadViewController(self, @selector(closeDownloadView:));
    vc.orientationDelegate = self;
    [self presentModalViewController:vc animated:YES];
}

The API result will be handled by the delegate that implements the MixiDelegate protocol that was given as a sendRequest method group parameter. For instance, to display the results of the API AlertView, give the sendRequest:delegate: method parameter as the class instance which defines a method like the following delegate method.

- (void)mixi:(Mixi*)mixi didFinishLoading:(NSString*)data {
    MixiUtilShowMessageTitle(data, @"result");
}

Please reference the MixiDelegate document for all other delegate methods.

TOP OF THIS PAGE