Repository: reactnativecn/react-native-weibo Branch: master Commit: 652f0071473a Files: 32 Total size: 23.9 MB Directory structure: gitextract_guyq7o2k/ ├── .gitignore ├── README.md ├── android/ │ ├── .gitignore │ ├── .npmignore │ ├── build.gradle │ ├── libs/ │ │ └── weiboSDKCore_3.1.2.jar │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── cn/ │ │ └── reactnative/ │ │ └── modules/ │ │ └── weibo/ │ │ └── ApplicationTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── cn/ │ │ │ └── reactnative/ │ │ │ └── modules/ │ │ │ └── weibo/ │ │ │ ├── WeiboModule.java │ │ │ └── WeiboPackage.java │ │ └── res/ │ │ └── values/ │ │ └── strings.xml │ └── test/ │ └── java/ │ └── cn/ │ └── reactnative/ │ └── modules/ │ └── weibo/ │ └── ExampleUnitTest.java ├── index.js ├── ios/ │ ├── RCTWeiboAPI/ │ │ ├── RCTWeiboAPI.h │ │ └── RCTWeiboAPI.m │ ├── RCTWeiboAPI.xcodeproj/ │ │ ├── project.pbxproj │ │ └── xcuserdata/ │ │ └── lvbingru.xcuserdatad/ │ │ └── xcschemes/ │ │ └── RCTWeiboAPI.xcscheme │ └── libWeiboSDK/ │ ├── WBHttpRequest+WeiboGame.h │ ├── WBHttpRequest+WeiboShare.h │ ├── WBHttpRequest+WeiboToken.h │ ├── WBHttpRequest+WeiboUser.h │ ├── WBHttpRequest.h │ ├── WBSDKBasicButton.h │ ├── WBSDKCommentButton.h │ ├── WBSDKRelationshipButton.h │ ├── WeiboSDK.bundle/ │ │ └── others/ │ │ ├── countryList │ │ └── mfp.cer │ ├── WeiboSDK.h │ ├── WeiboUser.h │ └── libWeiboSDK.a └── package.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ .idea ================================================ FILE: README.md ================================================ # react-native-weibo React Native的新浪微博登录插件, react-native版本需要0.17.0及以上 ## 如何安装 ### 1.首先安装npm包 ```bash npm install react-native-weibo --save ``` ### 2.link #### 自动link方法 ```bash react-native link ``` #### 手动link~(如果不能够自动link) #####ios a.打开XCode's工程中, 右键点击Libraries文件夹 ➜ Add Files to <...> b.去node_modules ➜ react-native-weibo ➜ ios ➜ 选择 RCTWeiboAPI.xcodeproj c.在工程Build Phases ➜ Link Binary With Libraries中添加libRCTWeiboAPI.a #####Android ``` // file: android/settings.gradle ... include ':react-native-weibo' project(':react-native-weibo').projectDir = new File(settingsDir, '../node_modules/react-native-weibo/android') ``` ``` // file: android/app/build.gradle ... dependencies { ... compile project(':react-native-weibo') } ``` `android/app/src/main/java/<你的包名>/MainApplication.java`中添加如下两行: ```java ... import cn.reactnative.modules.weibo.WeiboPackage; // 在public class MainApplication之前import public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override protected boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List getPackages() { return Arrays.asList(          new WeiboPackage(), // 然后添加这一行 new MainReactPackage() ); } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } } ``` ### 3.工程配置 #### ios配置 将`node_modules/react-native-weibo/ios/libWeiboSDK/WeiboSDK.bundle`加入到工程中(必须,很重要,不然登录的时候会crash) 在工程target的`Build Phases->Link Binary with Libraries`中加入`libRCTWeiboAPI.a、libsqlite3.tbd、libz.tbd、ImageIO.framework、SystemConfiguration.framework、Security.framework、CoreTelephony.framework、CoreText.framework` 在`Info->URL Types` 中增加QQ的scheme: `Identifier` 设置为`sina`, `URL Schemes` 设置为你注册的微博开发者账号中的APPID,需要加前缀`wb`,例如`wb1915346979` 在你工程的`AppDelegate.m`文件中添加如下代码: ``` #import "../Libraries/LinkingIOS/RCTLinkingManager.h" - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; } ``` ##### iOS9的适配问题 由于iOS9的发布影响了微博SDK与应用的集成方式,为了确保好的应用体验,我们需要采取如下措施: ##### a.对传输安全的支持 在iOS9系统中,默认需要为每次网络传输建立SSL。解决这个问题: - 将NSAllowsArbitraryLoads属性设置为YES,并添加到你应用的plist中 - NSAppTransportSecurity NSAllowsArbitraryLoads ###### b.对应用跳转的支持 如果你需要用到微博的相关功能,如登陆,分享等。并且需要实现跳转到微博的功能,在iOS9系统中就需要在你的app的plist中添加下列键值对。否则在canOpenURL函数执行时,就会返回NO。了解详情请至[https://developer.apple.com/videos/wwdc/2015/?id=703](https://developer.apple.com/videos/wwdc/2015/?id=703) - LSApplicationQueriesSchemes sinaweibohd sinaweibo weibosdk weibosdk2.5 #### Android 在`android/app/build.gradle`里,defaultConfig栏目下添加如下代码: ``` manifestPlaceholders = [ WB_APPID: "微博的APPID" //在此修改微博APPID ] ``` 如果react-native版本<0.18.0,确保你的MainActivity.java中有`onActivityResult`的实现: ```java private ReactInstanceManager mReactInstanceManager; @Override public void onActivityResult(int requestCode, int resultCode, Intent data){ super.onActivityResult(requestCode, resultCode, data); mReactInstanceManager.onActivityResult(requestCode, resultCode, data); } ``` ## 如何使用 ### 引入包 ``` import * as WeiboAPI from 'react-native-weibo'; ``` ### API #### WeiboAPI.login(config) ```javascript // 登录参数 config : { scope: 权限设置, // 默认 'all' redirectURI: 重定向地址, // 默认 'https://api.weibo.com/oauth2/default.html'(必须和sina微博开放平台中应用高级设置中的redirectURI设置的一致,不然会登录失败) } ``` 返回一个`Promise`对象。成功时的回调为一个类似这样的对象: ```javascript { "accessToken": "2.005e3HMBzh7eFCca6a3854060GQFJf", "userID": "1098604232" "expirationDate": "1452884401084.538" "refreshToken": "2.005e3HMBzh8eFC3db19a18bb00pvbp" } ``` #### WeiboAPI.share(data) 分享到微博 ```javascript // 分享文字 { type: 'text', text: 文字内容, } ``` ```javascript // 分享图片 { type: 'image', text: 文字内容, imageUrl: 图片地址 } ``` ================================================ FILE: android/.gitignore ================================================ /build ================================================ FILE: android/.npmignore ================================================ /build ================================================ FILE: android/build.gradle ================================================ apply plugin: 'com.android.library' android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets.main { jniLibs.srcDirs = ['libs'] } } dependencies { compile 'com.facebook.react:react-native:+' compile files('libs/weiboSDKCore_3.1.2.jar') } ================================================ FILE: android/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in /Users/lvbingru/Library/Android/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # Add any project specific keep options here: # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} ================================================ FILE: android/src/androidTest/java/cn/reactnative/modules/weibo/ApplicationTest.java ================================================ package cn.reactnative.modules.weibo; import android.app.Application; import android.test.ApplicationTestCase; /** * Testing Fundamentals */ public class ApplicationTest extends ApplicationTestCase { public ApplicationTest() { super(Application.class); } } ================================================ FILE: android/src/main/AndroidManifest.xml ================================================ ================================================ FILE: android/src/main/java/cn/reactnative/modules/weibo/WeiboModule.java ================================================ package cn.reactnative.modules.weibo; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.PixelFormat; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.NinePatchDrawable; import android.net.Uri; import android.os.Bundle; import android.util.Log; import com.facebook.common.executors.UiThreadImmediateExecutorService; import com.facebook.common.internal.Preconditions; import com.facebook.common.references.CloseableReference; import com.facebook.common.util.UriUtil; import com.facebook.datasource.BaseDataSubscriber; import com.facebook.datasource.DataSource; import com.facebook.datasource.DataSubscriber; import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.drawee.drawable.OrientedDrawable; import com.facebook.imagepipeline.common.ResizeOptions; import com.facebook.imagepipeline.core.ImagePipeline; import com.facebook.imagepipeline.image.CloseableImage; import com.facebook.imagepipeline.image.CloseableStaticBitmap; import com.facebook.imagepipeline.image.EncodedImage; import com.facebook.imagepipeline.request.ImageRequest; import com.facebook.imagepipeline.request.ImageRequestBuilder; import com.facebook.react.bridge.ActivityEventListener; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.WritableMap; import com.facebook.react.modules.core.RCTNativeAppEventEmitter; import com.sina.weibo.sdk.api.ImageObject; import com.sina.weibo.sdk.api.MusicObject; import com.sina.weibo.sdk.api.TextObject; import com.sina.weibo.sdk.api.VideoObject; import com.sina.weibo.sdk.api.WebpageObject; import com.sina.weibo.sdk.api.WeiboMultiMessage; import com.sina.weibo.sdk.api.share.BaseResponse; import com.sina.weibo.sdk.api.share.IWeiboHandler; import com.sina.weibo.sdk.api.share.IWeiboShareAPI; import com.sina.weibo.sdk.api.share.SendMultiMessageToWeiboRequest; import com.sina.weibo.sdk.api.share.WeiboShareSDK; import com.sina.weibo.sdk.auth.AuthInfo; import com.sina.weibo.sdk.auth.Oauth2AccessToken; import com.sina.weibo.sdk.auth.WeiboAuthListener; import com.sina.weibo.sdk.auth.sso.SsoHandler; import com.sina.weibo.sdk.exception.WeiboException; import java.util.Date; import javax.annotation.Nullable; /** * Created by lvbingru on 12/22/15. */ public class WeiboModule extends ReactContextBaseJavaModule implements ActivityEventListener { public WeiboModule(ReactApplicationContext reactContext) { super(reactContext); ApplicationInfo appInfo = null; try { appInfo = reactContext.getPackageManager().getApplicationInfo(reactContext.getPackageName(), PackageManager.GET_META_DATA); } catch (PackageManager.NameNotFoundException e) { throw new Error(e); } if (!appInfo.metaData.containsKey("WB_APPID")){ throw new Error("meta-data WB_APPID not found in AndroidManifest.xml"); } this.appId = appInfo.metaData.get("WB_APPID").toString(); this.appId = this.appId.substring(2); } private static final String RCTWBEventName = "Weibo_Resp"; private SsoHandler mSinaSsoHandler; private IWeiboShareAPI mSinaShareAPI; private String appId; private static final String RCTWBShareTypeNews = "news"; private static final String RCTWBShareTypeImage = "image"; private static final String RCTWBShareTypeText = "text"; private static final String RCTWBShareTypeVideo = "video"; private static final String RCTWBShareTypeAudio = "audio"; private static final String RCTWBShareType = "type"; private static final String RCTWBShareText = "text"; private static final String RCTWBShareTitle = "title"; private static final String RCTWBShareDescription = "description"; private static final String RCTWBShareWebpageUrl = "webpageUrl"; private static final String RCTWBShareImageUrl = "imageUrl"; private static final String RCTWBShareAccessToken = "accessToken"; private static WeiboModule gModule = null; @Override public void initialize() { super.initialize(); gModule = this; getReactApplicationContext().addActivityEventListener(this); } @Override public void onCatalystInstanceDestroy() { super.onCatalystInstanceDestroy(); gModule = null; getReactApplicationContext().removeActivityEventListener(this); } @Override public String getName() { return "RCTWeiboAPI"; } private IWeiboShareAPI registerShare() { if (mSinaShareAPI == null) { mSinaShareAPI = WeiboShareSDK.createWeiboAPI(getReactApplicationContext(), this.appId); mSinaShareAPI.registerApp(); } return mSinaShareAPI; } @ReactMethod public void login(final ReadableMap config, final Callback callback){ AuthInfo sinaAuthInfo = this._genAuthInfo(config); mSinaSsoHandler = new SsoHandler(getCurrentActivity(), sinaAuthInfo); mSinaSsoHandler.authorize(this.genWeiboAuthListener()); callback.invoke(); } @ReactMethod public void shareToWeibo(final ReadableMap data, Callback callback){ if (data.hasKey(RCTWBShareImageUrl)) { String imageUrl = data.getString(RCTWBShareImageUrl); DataSubscriber> dataSubscriber = new BaseDataSubscriber>() { @Override public void onNewResultImpl(DataSource> dataSource) { // isFinished must be obtained before image, otherwise we might set intermediate result // as final image. boolean isFinished = dataSource.isFinished(); // float progress = dataSource.getProgress(); CloseableReference image = dataSource.getResult(); if (image != null) { Drawable drawable = _createDrawable(image); Bitmap bitmap = _drawable2Bitmap(drawable); _share(data, bitmap); } else if (isFinished) { _share(data, null); } dataSource.close(); } @Override public void onFailureImpl(DataSource> dataSource) { dataSource.close(); _share(data, null); } @Override public void onProgressUpdate(DataSource> dataSource) { } }; ResizeOptions resizeOptions = null; if (!data.hasKey(RCTWBShareType) || !data.getString(RCTWBShareType).equals(RCTWBShareTypeImage)) { resizeOptions = new ResizeOptions(80, 80); } this._downloadImage(imageUrl, resizeOptions, dataSubscriber); } else { this._share(data, null); } callback.invoke(); } public void onActivityResult(int requestCode, int resultCode, Intent data) { if (mSinaSsoHandler != null) { mSinaSsoHandler.authorizeCallBack(requestCode, resultCode, data); mSinaSsoHandler = null; } } public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data){ this.onActivityResult(requestCode, resultCode, data); } public void onNewIntent(Intent intent){ } WeiboAuthListener genWeiboAuthListener() { return new WeiboAuthListener() { @Override public void onComplete(Bundle bundle) { final Oauth2AccessToken token = Oauth2AccessToken.parseAccessToken(bundle); WritableMap event = Arguments.createMap(); if (token.isSessionValid()) { event.putString("accessToken", token.getToken()); event.putDouble("expirationDate", token.getExpiresTime()); event.putString("userID", token.getUid()); event.putString("refreshToken", token.getRefreshToken()); event.putInt("errCode", 0); } else { // String code = bundle.getString("code", ""); event.putInt("errCode", -1); event.putString("errMsg", "token invalid"); } event.putString("type", "WBAuthorizeResponse"); getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class).emit(RCTWBEventName, event); } @Override public void onWeiboException(WeiboException e) { WritableMap event = Arguments.createMap(); event.putString("type", "WBAuthorizeResponse"); event.putString("errMsg", e.getMessage()); event.putInt("errCode", -1); getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class).emit(RCTWBEventName, event); } @Override public void onCancel() { WritableMap event = Arguments.createMap(); event.putString("type", "WBAuthorizeResponse"); event.putString("errMsg", "Cancel"); event.putInt("errCode", -1); getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class).emit(RCTWBEventName, event); } }; } private void _share(ReadableMap data, Bitmap bitmap) { this.registerShare(); WeiboMultiMessage weiboMessage = new WeiboMultiMessage();//初始化微博的分享消息 TextObject textObject = new TextObject(); if (data.hasKey(RCTWBShareText)) { textObject.text = data.getString(RCTWBShareText); } weiboMessage.textObject = textObject; String type = RCTWBShareTypeNews; if (data.hasKey(RCTWBShareType)){ type = data.getString(RCTWBShareType); } if (type.equals(RCTWBShareTypeText)) { } else if (type.equals(RCTWBShareTypeImage)) { ImageObject imageObject = new ImageObject(); if (bitmap != null) { Log.e("share","hasBitmap"); imageObject.setImageObject(bitmap); } weiboMessage.imageObject = imageObject; } else { if (type.equals(RCTWBShareTypeNews)) { WebpageObject webpageObject = new WebpageObject(); if (data.hasKey(RCTWBShareWebpageUrl)) { webpageObject.actionUrl = data.getString(RCTWBShareWebpageUrl); } weiboMessage.mediaObject = webpageObject; } else if (type.equals(RCTWBShareTypeVideo)) { VideoObject videoObject = new VideoObject(); if (data.hasKey(RCTWBShareWebpageUrl)) { videoObject.dataUrl = data.getString(RCTWBShareWebpageUrl); } weiboMessage.mediaObject = videoObject; } else if (type.equals(RCTWBShareTypeAudio)) { MusicObject musicObject = new MusicObject(); if (data.hasKey(RCTWBShareWebpageUrl)) { musicObject.dataUrl = data.getString(RCTWBShareWebpageUrl); } weiboMessage.mediaObject = musicObject; } if (data.hasKey(RCTWBShareDescription)) { weiboMessage.mediaObject.description = data.getString(RCTWBShareDescription); } if (data.hasKey(RCTWBShareTitle)) { weiboMessage.mediaObject.title = data.getString(RCTWBShareTitle); } if (bitmap != null) { weiboMessage.mediaObject.setThumbImage(bitmap); } weiboMessage.mediaObject.identify = new Date().toString(); } SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest(); request.transaction = String.valueOf(System.currentTimeMillis()); request.multiMessage = weiboMessage; String accessToken = null; if (data.hasKey(RCTWBShareAccessToken)) { accessToken = data.getString(RCTWBShareAccessToken); } boolean success = mSinaShareAPI.sendRequest(getCurrentActivity(), request, null, accessToken, genWeiboAuthListener()); if (success == false) { WritableMap event = Arguments.createMap(); event.putString("type", "WBAuthorizeResponse"); event.putString("errMsg", "WeiBo API invoke returns false."); event.putInt("errCode", -1); getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class).emit(RCTWBEventName, event); } } public static boolean handleWeiboResponse(Intent intent, IWeiboHandler.Response response) { gModule.registerShare(); boolean ret = gModule.mSinaShareAPI.handleWeiboResponse(intent, response); if (ret) { return ret; } return ret; } public static void onShareResponse(BaseResponse baseResponse) { WritableMap map = Arguments.createMap(); map.putInt("errCode", baseResponse.errCode); map.putString("errMsg", baseResponse.errMsg); map.putString("type", "WBSendMessageToWeiboResponse"); gModule.getReactApplicationContext() .getJSModule(RCTNativeAppEventEmitter.class) .emit(RCTWBEventName, map); } static public class SinaEntryActivity extends Activity implements IWeiboHandler.Response { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WeiboModule.handleWeiboResponse(getIntent(), this); } @Override public void onResponse(BaseResponse baseResponse) { WeiboModule.onShareResponse(baseResponse); this.finish(); } } private AuthInfo _genAuthInfo(ReadableMap config) { String redirectURI = ""; if (config.hasKey("redirectURI")) { redirectURI = config.getString("redirectURI"); } String scope = ""; if (config.hasKey("scope")) { scope = config.getString("scope"); } final AuthInfo sinaAuthInfo = new AuthInfo(getReactApplicationContext(), this.appId, redirectURI, scope); return sinaAuthInfo; } private void _downloadImage(String imageUrl, ResizeOptions resizeOptions,DataSubscriber> dataSubscriber) { Uri uri = null; try { uri = Uri.parse(imageUrl); // Verify scheme is set, so that relative uri (used by static resources) are not handled. if (uri.getScheme() == null) { uri = null; } } catch (Exception e) { // ignore malformed uri, then attempt to extract resource ID. } if (uri == null) { uri = _getResourceDrawableUri(getReactApplicationContext(), imageUrl); } else { } ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(uri); if (resizeOptions != null) { builder.setResizeOptions(resizeOptions); } ImageRequest imageRequest = builder.build(); ImagePipeline imagePipeline = Fresco.getImagePipeline(); DataSource> dataSource = imagePipeline.fetchDecodedImage(imageRequest, null); dataSource.subscribe(dataSubscriber, UiThreadImmediateExecutorService.getInstance()); } private static @Nullable Uri _getResourceDrawableUri(Context context, @Nullable String name) { if (name == null || name.isEmpty()) { return null; } name = name.toLowerCase().replace("-", "_"); int resId = context.getResources().getIdentifier( name, "drawable", context.getPackageName()); return new Uri.Builder() .scheme(UriUtil.LOCAL_RESOURCE_SCHEME) .path(String.valueOf(resId)) .build(); } private Drawable _createDrawable(CloseableReference image) { Preconditions.checkState(CloseableReference.isValid(image)); CloseableImage closeableImage = image.get(); if (closeableImage instanceof CloseableStaticBitmap) { CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) closeableImage; BitmapDrawable bitmapDrawable = new BitmapDrawable( getReactApplicationContext().getResources(), closeableStaticBitmap.getUnderlyingBitmap()); if (closeableStaticBitmap.getRotationAngle() == 0 || closeableStaticBitmap.getRotationAngle() == EncodedImage.UNKNOWN_ROTATION_ANGLE) { return bitmapDrawable; } else { return new OrientedDrawable(bitmapDrawable, closeableStaticBitmap.getRotationAngle()); } } else { throw new UnsupportedOperationException("Unrecognized image class: " + closeableImage); } } private Bitmap _drawable2Bitmap(Drawable drawable) { if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof NinePatchDrawable) { Bitmap bitmap = Bitmap .createBitmap( drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.draw(canvas); return bitmap; } else { return null; } } } ================================================ FILE: android/src/main/java/cn/reactnative/modules/weibo/WeiboPackage.java ================================================ package cn.reactnative.modules.weibo; import com.facebook.react.ReactPackage; import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; import java.util.Arrays; import java.util.Collections; import java.util.List; /** * Created by lvbingru on 12/22/15. */ public class WeiboPackage implements ReactPackage { @Override public List createNativeModules(ReactApplicationContext reactContext) { return Arrays.asList(new NativeModule[]{ // Modules from third-party new WeiboModule(reactContext), }); } public List> createJSModules() { return Collections.emptyList(); } @Override public List createViewManagers(ReactApplicationContext reactContext) { return Collections.emptyList(); } } ================================================ FILE: android/src/main/res/values/strings.xml ================================================ react-native-weibo ================================================ FILE: android/src/test/java/cn/reactnative/modules/weibo/ExampleUnitTest.java ================================================ package cn.reactnative.modules.weibo; import org.junit.Test; import static org.junit.Assert.*; /** * To work on unit tests, switch the Test Artifact in the Build Variants view. */ public class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { assertEquals(4, 2 + 2); } } ================================================ FILE: index.js ================================================ /** * Created by lvbingru on 1/5/16. */ import {NativeModules, NativeAppEventEmitter} from 'react-native'; import promisify from 'es6-promisify'; const {WeiboAPI} = NativeModules; // Used only with promisify. Transform callback to promise result. function translateError(err, result) { if (!err) { return this.resolve(result); } if (typeof err === 'object') { if (err instanceof Error) { return this.reject(ret); } return this.reject(Object.assign(new Error(err.message), { errCode: err.errCode })); } else if (typeof err === 'string') { return this.reject(new Error(err)); } this.reject(Object.assign(new Error(), { origin: err })); } function wrapApi(nativeFunc) { if (!nativeFunc) { return undefined; } const promisified = promisify(nativeFunc, translateError); return (...args) => { return promisified(...args); }; } // Save callback and wait for future event. let savedCallback = undefined; function waitForResponse(type) { return new Promise((resolve, reject) => { if (savedCallback) { savedCallback('User canceled.'); } savedCallback = result => { if (result.type !== type) { return; } savedCallback = undefined; if (result.errCode !== 0) { const err = new Error(result.errMsg); err.errCode = result.errCode; reject(err); } else { resolve(result); } }; }); } NativeAppEventEmitter.addListener('Weibo_Resp', resp => { const callback = savedCallback; savedCallback = undefined; callback && callback(resp); }); const defaultScope = "all" const defaultRedirectURI = "https://api.weibo.com/oauth2/default.html" function checkData(data) { if(!data.redirectURI) { data.redirectURI = defaultRedirectURI } if(!data.scope) { data.scope = defaultScope } } const nativeSendAuthRequest = wrapApi(WeiboAPI.login); const nativeSendMessageRequest = wrapApi(WeiboAPI.shareToWeibo); export function login(config={}) { checkData(config) return Promise.all([waitForResponse('WBAuthorizeResponse'), nativeSendAuthRequest(config)]).then(v=>v[0]); } export function share(data) { checkData(data) return Promise.all([waitForResponse('WBSendMessageToWeiboResponse'), nativeSendMessageRequest(data)]).then(v=>v[0]); } ================================================ FILE: ios/RCTWeiboAPI/RCTWeiboAPI.h ================================================ // // RCTWeiboAPI.h // RCTWeiboAPI // // Created by LvBingru on 1/6/16. // Copyright © 2016 erica. All rights reserved. // #import "RCTBridgeModule.h" @interface RCTWeiboAPI : NSObject @end ================================================ FILE: ios/RCTWeiboAPI/RCTWeiboAPI.m ================================================ // // RCTWeiboAPI.m // RCTWeiboAPI // // Created by LvBingru on 1/6/16. // Copyright © 2016 erica. All rights reserved. // #import "RCTWeiboAPI.h" #import "WeiboSDK.h" #if __has_include() #import #import #import #else #import "RCTBridge.h" #import "RCTEventDispatcher.h" #import "RCTImageLoader.h" #endif #define INVOKE_FAILED (@"WeiBo API invoke returns false.") #define RCTWBEventName (@"Weibo_Resp") #define RCTWBShareTypeNews @"news" #define RCTWBShareTypeImage @"image" #define RCTWBShareTypeText @"text" #define RCTWBShareTypeVideo @"video" #define RCTWBShareTypeAudio @"audio" #define RCTWBShareType @"type" #define RCTWBShareText @"text" #define RCTWBShareTitle @"title" #define RCTWBShareDescription @"description" #define RCTWBShareWebpageUrl @"webpageUrl" #define RCTWBShareImageUrl @"imageUrl" #define RCTWBShareAccessToken @"accessToken" BOOL gRegister = NO; @interface RCTWeiboAPI() @end @implementation RCTWeiboAPI @synthesize bridge = _bridge; RCT_EXPORT_MODULE(); - (dispatch_queue_t)methodQueue { return dispatch_get_main_queue(); } - (instancetype)init { self = [super init]; if (self) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:@"RCTOpenURLNotification" object:nil]; } return self; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } RCT_EXPORT_METHOD(login:(NSDictionary *)config :(RCTResponseSenderBlock)callback) { [self _autoRegisterAPI]; WBAuthorizeRequest *request = [self _genAuthRequest:config]; BOOL success = [WeiboSDK sendRequest:request]; callback(@[success?[NSNull null]:INVOKE_FAILED]); } RCT_EXPORT_METHOD(logout) { [WeiboSDK logOutWithToken:nil delegate:nil withTag:nil]; } RCT_EXPORT_METHOD(shareToWeibo:(NSDictionary *)aData :(RCTResponseSenderBlock)callback) { [self _autoRegisterAPI]; NSString *imageUrl = aData[RCTWBShareImageUrl]; if (imageUrl.length && _bridge.imageLoader) { CGSize size = CGSizeZero; if (![aData[RCTWBShareType] isEqualToString:RCTWBShareTypeImage]) { size = CGSizeMake(80,80); } [_bridge.imageLoader loadImageWithURLRequest:[RCTConvert NSURLRequest:imageUrl] size:size scale:1 clipped:FALSE resizeMode:UIViewContentModeScaleToFill progressBlock:nil partialLoadBlock: nil completionBlock:^(NSError *error, UIImage *image) { [self _shareWithData:aData image:image]; }]; } else { [self _shareWithData:aData image:nil]; } callback(@[[NSNull null]]); } - (void)handleOpenURL:(NSNotification *)note { NSDictionary *userInfo = note.userInfo; NSString *url = userInfo[@"url"]; [WeiboSDK handleOpenURL:[NSURL URLWithString:url] delegate:self]; } #pragma mark - sina delegate - (void)didReceiveWeiboRequest:(WBBaseRequest *)request { if ([request isKindOfClass:WBProvideMessageForWeiboRequest.class]) { } } - (void)didReceiveWeiboResponse:(WBBaseResponse *)response { NSMutableDictionary *body = [NSMutableDictionary new]; body[@"errCode"] = @(response.statusCode); // 分享 if ([response isKindOfClass:WBSendMessageToWeiboResponse.class]) { body[@"type"] = @"WBSendMessageToWeiboResponse"; if (response.statusCode == WeiboSDKResponseStatusCodeSuccess) { WBSendMessageToWeiboResponse *sendResponse = (WBSendMessageToWeiboResponse *)response; WBAuthorizeResponse *authorizeResponse = sendResponse.authResponse; if (sendResponse.authResponse != nil) { body[@"userID"] = authorizeResponse.userID; body[@"accessToken"] = authorizeResponse.accessToken; body[@"expirationDate"] = @([authorizeResponse.expirationDate timeIntervalSince1970]); body[@"refreshToken"] = authorizeResponse.refreshToken; } } else { body[@"errMsg"] = [self _getErrMsg:response.statusCode]; } } // 认证 else if ([response isKindOfClass:WBAuthorizeResponse.class]) { body[@"type"] = @"WBAuthorizeResponse"; if (response.statusCode == WeiboSDKResponseStatusCodeSuccess) { WBAuthorizeResponse *authorizeResponse = (WBAuthorizeResponse *)response; body[@"userID"] = authorizeResponse.userID; body[@"accessToken"] = authorizeResponse.accessToken; body[@"expirationDate"] = @([authorizeResponse.expirationDate timeIntervalSince1970]*1000); body[@"refreshToken"] = authorizeResponse.refreshToken; } else { body[@"errMsg"] = [self _getErrMsg:response.statusCode]; } } [self.bridge.eventDispatcher sendAppEventWithName:RCTWBEventName body:body]; } #pragma mark - private // 如果js没有调用registerApp,自动从plist中读取appId - (void)_autoRegisterAPI { if (gRegister) { return; } NSArray *list = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleURLTypes"]; for (NSDictionary *item in list) { NSString *name = item[@"CFBundleURLName"]; if ([name isEqualToString:@"sina"]) { NSArray *schemes = item[@"CFBundleURLSchemes"]; if (schemes.count > 0) { NSString *appId = [schemes[0] substringFromIndex:@"wb".length]; if ([WeiboSDK registerApp:appId]) { gRegister = YES; } #ifdef DEBUG [WeiboSDK enableDebugMode:YES]; #endif break; } } } } - (NSString *)_getErrMsg:(NSInteger)errCode { NSString *errMsg = @"微博认证失败"; switch (errCode) { case WeiboSDKResponseStatusCodeUserCancel: errMsg = @"用户取消发送"; break; case WeiboSDKResponseStatusCodeSentFail: errMsg = @"发送失败"; break; case WeiboSDKResponseStatusCodeAuthDeny: errMsg = @"授权失败"; break; case WeiboSDKResponseStatusCodeUserCancelInstall: errMsg = @"用户取消安装微博客户端"; break; case WeiboSDKResponseStatusCodePayFail: errMsg = @"支付失败"; break; case WeiboSDKResponseStatusCodeShareInSDKFailed: errMsg = @"分享失败"; break; case WeiboSDKResponseStatusCodeUnsupport: errMsg = @"不支持的请求"; break; default: errMsg = @"位置"; break; } return errMsg; } - (void)_shareWithData:(NSDictionary *)aData image:(UIImage *)aImage { WBMessageObject *message = [WBMessageObject message]; NSString *text = aData[RCTWBShareText]; message.text = text; NSString *type = aData[RCTWBShareType]; if ([type isEqualToString:RCTWBShareTypeText]) { } else if ([type isEqualToString:RCTWBShareTypeImage]) { // 大小不能超过10M WBImageObject *imageObject = [WBImageObject new]; if (aImage) { imageObject.imageData = UIImageJPEGRepresentation(aImage, 0.7); } message.imageObject = imageObject; } else { if ([type isEqualToString:RCTWBShareTypeVideo]) { WBVideoObject *videoObject = [WBVideoObject new]; videoObject.videoUrl = aData[RCTWBShareWebpageUrl]; message.mediaObject = videoObject; } else if ([type isEqualToString:RCTWBShareTypeAudio]) { WBMusicObject *musicObject = [WBMusicObject new]; musicObject.musicUrl = aData[RCTWBShareWebpageUrl]; message.mediaObject = musicObject; } else { WBWebpageObject *webpageObject = [WBWebpageObject new]; webpageObject.webpageUrl = aData[RCTWBShareWebpageUrl]; message.mediaObject = webpageObject; } message.mediaObject.objectID = [NSDate date].description; message.mediaObject.description = aData[RCTWBShareDescription]; message.mediaObject.title = aData[RCTWBShareTitle]; if (aImage) { // @warning 大小小于32k message.mediaObject.thumbnailData = UIImageJPEGRepresentation(aImage, 0.7); } } WBAuthorizeRequest *authRequest = [self _genAuthRequest:aData]; NSString *accessToken = aData[RCTWBShareAccessToken]; WBSendMessageToWeiboRequest *request = [WBSendMessageToWeiboRequest requestWithMessage:message authInfo:authRequest access_token:accessToken]; BOOL success = [WeiboSDK sendRequest:request]; if (!success) { NSMutableDictionary *body = [NSMutableDictionary new]; body[@"errMsg"] = INVOKE_FAILED; body[@"errCode"] = @(-1); body[@"type"] = @"WBSendMessageToWeiboResponse"; [_bridge.eventDispatcher sendAppEventWithName:RCTWBEventName body:body]; } } - (WBAuthorizeRequest *)_genAuthRequest:(NSDictionary *)config { NSString *redirectURI = config[@"redirectURI"]; NSString *scope = config[@"scope"]; WBAuthorizeRequest *authRequest = [WBAuthorizeRequest request]; authRequest.redirectURI = redirectURI; authRequest.scope = scope; return authRequest; } @end ================================================ FILE: ios/RCTWeiboAPI.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ 915450F91C3D1520000CBFD2 /* RCTWeiboAPI.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 915450F81C3D1520000CBFD2 /* RCTWeiboAPI.h */; }; 915450FB1C3D1520000CBFD2 /* RCTWeiboAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = 915450FA1C3D1520000CBFD2 /* RCTWeiboAPI.m */; }; 9154511B1C3D161E000CBFD2 /* libWeiboSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9154510F1C3D161E000CBFD2 /* libWeiboSDK.a */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ 915450F31C3D1520000CBFD2 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = "include/$(PRODUCT_NAME)"; dstSubfolderSpec = 16; files = ( 915450F91C3D1520000CBFD2 /* RCTWeiboAPI.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ 915450F51C3D1520000CBFD2 /* libRCTWeiboAPI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTWeiboAPI.a; sourceTree = BUILT_PRODUCTS_DIR; }; 915450F81C3D1520000CBFD2 /* RCTWeiboAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTWeiboAPI.h; sourceTree = ""; }; 915450FA1C3D1520000CBFD2 /* RCTWeiboAPI.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTWeiboAPI.m; sourceTree = ""; }; 9154510F1C3D161E000CBFD2 /* libWeiboSDK.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libWeiboSDK.a; sourceTree = ""; }; 915451101C3D161E000CBFD2 /* WBHttpRequest+WeiboGame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WBHttpRequest+WeiboGame.h"; sourceTree = ""; }; 915451111C3D161E000CBFD2 /* WBHttpRequest+WeiboShare.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WBHttpRequest+WeiboShare.h"; sourceTree = ""; }; 915451121C3D161E000CBFD2 /* WBHttpRequest+WeiboToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WBHttpRequest+WeiboToken.h"; sourceTree = ""; }; 915451131C3D161E000CBFD2 /* WBHttpRequest+WeiboUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WBHttpRequest+WeiboUser.h"; sourceTree = ""; }; 915451141C3D161E000CBFD2 /* WBHttpRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBHttpRequest.h; sourceTree = ""; }; 915451151C3D161E000CBFD2 /* WBSDKBasicButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBSDKBasicButton.h; sourceTree = ""; }; 915451161C3D161E000CBFD2 /* WBSDKCommentButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBSDKCommentButton.h; sourceTree = ""; }; 915451171C3D161E000CBFD2 /* WBSDKRelationshipButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBSDKRelationshipButton.h; sourceTree = ""; }; 915451181C3D161E000CBFD2 /* WeiboSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = WeiboSDK.bundle; sourceTree = ""; }; 915451191C3D161E000CBFD2 /* WeiboSDK.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeiboSDK.h; sourceTree = ""; }; 9154511A1C3D161E000CBFD2 /* WeiboUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeiboUser.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 915450F21C3D1520000CBFD2 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 9154511B1C3D161E000CBFD2 /* libWeiboSDK.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 915450EC1C3D1520000CBFD2 = { isa = PBXGroup; children = ( 9154510E1C3D161E000CBFD2 /* libWeiboSDK */, 915450F71C3D1520000CBFD2 /* RCTWeiboAPI */, 915450F61C3D1520000CBFD2 /* Products */, ); sourceTree = ""; }; 915450F61C3D1520000CBFD2 /* Products */ = { isa = PBXGroup; children = ( 915450F51C3D1520000CBFD2 /* libRCTWeiboAPI.a */, ); name = Products; sourceTree = ""; }; 915450F71C3D1520000CBFD2 /* RCTWeiboAPI */ = { isa = PBXGroup; children = ( 915450F81C3D1520000CBFD2 /* RCTWeiboAPI.h */, 915450FA1C3D1520000CBFD2 /* RCTWeiboAPI.m */, ); path = RCTWeiboAPI; sourceTree = ""; }; 9154510E1C3D161E000CBFD2 /* libWeiboSDK */ = { isa = PBXGroup; children = ( 9154510F1C3D161E000CBFD2 /* libWeiboSDK.a */, 915451101C3D161E000CBFD2 /* WBHttpRequest+WeiboGame.h */, 915451111C3D161E000CBFD2 /* WBHttpRequest+WeiboShare.h */, 915451121C3D161E000CBFD2 /* WBHttpRequest+WeiboToken.h */, 915451131C3D161E000CBFD2 /* WBHttpRequest+WeiboUser.h */, 915451141C3D161E000CBFD2 /* WBHttpRequest.h */, 915451151C3D161E000CBFD2 /* WBSDKBasicButton.h */, 915451161C3D161E000CBFD2 /* WBSDKCommentButton.h */, 915451171C3D161E000CBFD2 /* WBSDKRelationshipButton.h */, 915451181C3D161E000CBFD2 /* WeiboSDK.bundle */, 915451191C3D161E000CBFD2 /* WeiboSDK.h */, 9154511A1C3D161E000CBFD2 /* WeiboUser.h */, ); path = libWeiboSDK; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ 915450F41C3D1520000CBFD2 /* RCTWeiboAPI */ = { isa = PBXNativeTarget; buildConfigurationList = 915450FE1C3D1520000CBFD2 /* Build configuration list for PBXNativeTarget "RCTWeiboAPI" */; buildPhases = ( 915450F11C3D1520000CBFD2 /* Sources */, 915450F21C3D1520000CBFD2 /* Frameworks */, 915450F31C3D1520000CBFD2 /* CopyFiles */, ); buildRules = ( ); dependencies = ( ); name = RCTWeiboAPI; productName = RCTWeiboAPI; productReference = 915450F51C3D1520000CBFD2 /* libRCTWeiboAPI.a */; productType = "com.apple.product-type.library.static"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 915450ED1C3D1520000CBFD2 /* Project object */ = { isa = PBXProject; attributes = { LastUpgradeCheck = 0720; ORGANIZATIONNAME = erica; TargetAttributes = { 915450F41C3D1520000CBFD2 = { CreatedOnToolsVersion = 7.2; }; }; }; buildConfigurationList = 915450F01C3D1520000CBFD2 /* Build configuration list for PBXProject "RCTWeiboAPI" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, ); mainGroup = 915450EC1C3D1520000CBFD2; productRefGroup = 915450F61C3D1520000CBFD2 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( 915450F41C3D1520000CBFD2 /* RCTWeiboAPI */, ); }; /* End PBXProject section */ /* Begin PBXSourcesBuildPhase section */ 915450F11C3D1520000CBFD2 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 915450FB1C3D1520000CBFD2 /* RCTWeiboAPI.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ 915450FC1C3D1520000CBFD2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.2; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; name = Debug; }; 915450FD1C3D1520000CBFD2 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.2; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; name = Release; }; 915450FF1C3D1520000CBFD2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../../react-native/React/**", "$(SRCROOT)/../../react-native/Libraries/**", "$(BUILT_PRODUCTS_DIR)/include/**", ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/libWeiboSDK", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; name = Debug; }; 915451001C3D1520000CBFD2 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { HEADER_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../../react-native/React/**", "$(SRCROOT)/../../react-native/Libraries/**", "$(BUILT_PRODUCTS_DIR)/include/**", ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/libWeiboSDK", ); OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 915450F01C3D1520000CBFD2 /* Build configuration list for PBXProject "RCTWeiboAPI" */ = { isa = XCConfigurationList; buildConfigurations = ( 915450FC1C3D1520000CBFD2 /* Debug */, 915450FD1C3D1520000CBFD2 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 915450FE1C3D1520000CBFD2 /* Build configuration list for PBXNativeTarget "RCTWeiboAPI" */ = { isa = XCConfigurationList; buildConfigurations = ( 915450FF1C3D1520000CBFD2 /* Debug */, 915451001C3D1520000CBFD2 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 915450ED1C3D1520000CBFD2 /* Project object */; } ================================================ FILE: ios/RCTWeiboAPI.xcodeproj/xcuserdata/lvbingru.xcuserdatad/xcschemes/RCTWeiboAPI.xcscheme ================================================ ================================================ FILE: ios/libWeiboSDK/WBHttpRequest+WeiboGame.h ================================================ // // WBHttpRequest+WeiboGame.h // WeiboSDK // // Created by insomnia on 15/3/11. // Copyright (c) 2015年 SINA iOS Team. All rights reserved. // #import "WBHttpRequest.h" @interface WBHttpRequest (WeiboGame) /*! @method @abstract 新增游戏对象。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 @param userID 当前授权用户的uid @param accessToken 当前授权用户的accessToken @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 */ + (WBHttpRequest *)addGameObject:(NSString*)userID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract 游戏成就对象入库/更新。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 @param userID 当前授权用户的uid @param accessToken 当前授权用户的accessToken @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 */ + (WBHttpRequest *)addGameAchievementObject:(NSString*)userID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract 用户获得游戏成就关系入库/更新。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 @param userID 当前授权用户的uid @param accessToken 当前授权用户的accessToken @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 */ + (WBHttpRequest *)addGameAchievementGain:(NSString*)userID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract 用户游戏得分关系入库/更新。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 @param userID 当前授权用户的uid @param accessToken 当前授权用户的accessToken @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 */ + (WBHttpRequest *)addGameScoreGain:(NSString*)userID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract 读取玩家游戏分数。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 @param userID 当前授权用户的uid @param accessToken 当前授权用户的accessToken @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 */ + (WBHttpRequest *)requestForGameScore:(NSString*)userID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract 读取玩家互粉好友游戏分数。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 @param userID 当前授权用户的uid @param accessToken 当前授权用户的accessToken @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 */ + (WBHttpRequest *)requestForFriendsGameScore:(NSString*)userID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract 读取玩家获取成就列表。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 @param userID 当前授权用户的uid @param accessToken 当前授权用户的accessToken @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 */ + (WBHttpRequest *)requestForGameAchievementGain:(NSString*)userID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; @end ================================================ FILE: ios/libWeiboSDK/WBHttpRequest+WeiboShare.h ================================================ // // WBHttpRequest+WeiboShare.h // WeiboSDK // // Created by DannionQiu on 14/10/31. // Copyright (c) 2014年 SINA iOS Team. All rights reserved. // #import "WBHttpRequest.h" @class WBImageObject; @interface WBHttpRequest (WeiboShare) /*! @method @abstract 获得当前授权用户的微博id列表。 @param userID 当前授权用户的uid @param accessToken 当前授权用户的accessToken @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 */ + (WBHttpRequest *)requestForStatusIDsFromCurrentUser:(NSString*)userID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract 转发微博。转发微博id所对应的微博。 @param statusID 微博id,微博的唯一标识符。 @param text 添加的转发文本,内容不超过140个汉字,不填则默认为“转发微博”。 @param accessToken 当前授权用户的accessToken @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 */ + (WBHttpRequest *)requestForRepostAStatus:(NSString*)statusID repostText:(NSString*)text withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract 发表一个微博(无图或者带一张图片的微博)。 @param statusText 要发布的微博文本内容,内容不超过140个汉字。 @param imageObject 要上传的图片,仅支持JPEG、GIF、PNG格式,图片大小小于5M。这个参数可为nil。由于只能传一张图片,若imageObject和url都有值,请看@caution。 @param url 图片的URL地址,必须以http开头。这个参数可为nil,由于只能传一张图片,若imageObject和url都有值,请看@caution。 @param accessToken 当前授权用户的accessToken @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 @caution 注意,如果参数imageObject和url都有值,则发布带有imageObject所对应的图片,忽略url所对应的图片。 */ + (WBHttpRequest *)requestForShareAStatus:(NSString*)statusText contatinsAPicture:(WBImageObject*)imageObject orPictureUrl:(NSString*)url withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; @end ================================================ FILE: ios/libWeiboSDK/WBHttpRequest+WeiboToken.h ================================================ // // WBHttpRequest+WeiboToken.h // WeiboSDK // // Created by DannionQiu on 14/11/6. // Copyright (c) 2014年 SINA iOS Team. All rights reserved. // #import "WBHttpRequest.h" @interface WBHttpRequest (WeiboToken) /*! @method @abstract 使用RefreshToken去换取新的身份凭证AccessToken. @discussion 在SSO授权登录后,服务器会下发有效期为7天的refreshToken以及有效期为1天的AccessToken。 当有效期为1天的AccessToken过期时,可以调用该接口带着refreshToken信息区换取新的AccessToken。 @param refreshToken refreshToken @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 */ + (WBHttpRequest *)requestForRenewAccessTokenWithRefreshToken:(NSString*)refreshToken queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; @end ================================================ FILE: ios/libWeiboSDK/WBHttpRequest+WeiboUser.h ================================================ // // WBHttpRequest+WeiboUser.h // WeiboSDK // // Created by DannionQiu on 14-9-23. // Copyright (c) 2014年 SINA iOS Team. All rights reserved. // #import "WBHttpRequest.h" @interface WBHttpRequest (WeiboUser) /*! @method @abstract Creates a request representing a Open API call to the "friendships/friends". @discussion Simplifies preparing a request and sending request to retrieve the user's friends. A successful Open API call will return an NSDictionary of objects which contanis an array of objects representing the user's friends. You can see more details about this API in http://open.weibo.com/wiki/2/friendships/friends/en @param currentUserID should be the current User's UserID which has been authorized. @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForFriendsListOfUser:(NSString*)currentUserID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "friendships/friends/ids". @discussion Simplifies preparing a request and sending request to retrieve the user's friends' UserID. A successful Open API call will return an NSDictionary of objects which contanis an array of NSString representing the user's friends' UserID. You can see more details about this API in http://open.weibo.com/wiki/2/friendships/friends/ids/en @param currentUserID should be the current User's UserID which has been authorized. @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForFriendsUserIDListOfUser:(NSString*)currentUserID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "friendships/friends/in_common". @discussion Simplifies preparing a request and sending request to retrieve the common friends list between two users.. A successful Open API call will return an NSDictionary of objects which contanis an array of objects representing the user's friends. You can see more details about this API in http://open.weibo.com/wiki/2/friendships/friends/in_common/en @param currentUserID should be the current User's UserID which has been authorized. @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForCommonFriendsListBetweenUser:(NSString*)currentUserID andUser:(NSString*)anotherUserID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "friendships/friends/bilateral". @discussion Simplifies preparing a request and sending request to retrieve the list of the users that are following the specified user and are being followed by the specified user. A successful Open API call will return an NSDictionary of objects which contanis an array of objects representing the users that are following the specified user and are being followed by the specified user. You can see more details about this API in http://open.weibo.com/wiki/2/friendships/friends/bilateral/en @param currentUserID should be the current User's UserID which has been authorized. @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForBilateralFriendsListOfUser:(NSString*)currentUserID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "friendships/followers". @discussion Simplifies preparing a request and sending request to retrieve the user's followers. A successful Open API call will return an NSDictionary of objects which contanis an array of objects representing the user's followers. You can see more details about this API in http://open.weibo.com/wiki/2/friendships/followers/en @param currentUserID should be the current User's UserID which has been authorized. @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForFollowersListOfUser:(NSString*)currentUserID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "friendships/followers/ids". @discussion Simplifies preparing a request and sending request to retrieve the user's followers' UserID. A successful Open API call will return an NSDictionary of objects which contanis an array of NSString representing the user's followers' UserID. You can see more details about this API in http://open.weibo.com/wiki/2/friendships/followers/ids/en @param currentUserID should be the current User's UserID which has been authorized. @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForFollowersUserIDListOfUser:(NSString*)currentUserID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "friendships/followers/active". @discussion Simplifies preparing a request and sending request to retrieve the active(high quality) followers list of a user. A successful Open API call will return an NSDictionary of objects which contanis an array of objects representing the active(high quality) followers list of a user. You can see more details about this API in http://open.weibo.com/wiki/2/friendships/followers/active/en @param currentUserID should be the current User's UserID which has been authorized. @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForActiveFollowersListOfUser:(NSString*)currentUserID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "friendships/friends_chain/followers". @discussion Simplifies preparing a request and sending request to retrieve the users that are being followed by the authenticating user and are following the specified user. A successful Open API call will return an NSDictionary of objects which contanis an array of objects representing the users that are being followed by the authenticating user and are following the specified user. You can see more details about this API in http://open.weibo.com/wiki/2/friendships/friends_chain/followers/en @param currentUserID should be the current User's UserID which has been authorized. @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForBilateralFollowersListOfUser:(NSString*)currentUserID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "friendships/show". @discussion Simplifies preparing a request and sending request to retrieve the relationship of two users. A successful Open API call will return an NSDictionary of objects which contanis the relationship of two users. You can see more details about this API in http://open.weibo.com/wiki/2/friendships/show @param targetUserID a User ID @param sourceUserID a User ID @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForFriendshipDetailBetweenTargetUser:(NSString*)targetUserID andSourceUser:(NSString*)sourceUserID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "friendships/create". @discussion Simplifies preparing a request and sending request to Follow a user. A successful Open API call will return an object representing the user to be followed. You can see more details about this API in http://open.weibo.com/wiki/2/friendships/create/en @param theUserToBeFollowed the userID of the user which you want to follow. @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForFollowAUser:(NSString*)theUserToBeFollowed withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "friendships/destroy". @discussion Simplifies preparing a request and sending request to cancel following a user. A successful Open API call will return an object representing the user to be followed. You can see more details about this API in http://open.weibo.com/wiki/2/friendships/destroy/en @param theUserThatYouDontLike the userID of the user which you want to cancel following. @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForCancelFollowAUser:(NSString*)theUserThatYouDontLike withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "friendships/followers/destroy". @discussion Simplifies preparing a request and sending request to remove a follower of the authenticating user. A successful Open API call will return an object representing the user to be followed. this API requires advanced level authorization. You can see more details about advanced level authorization in http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E#scope You can see more details about this API in http://open.weibo.com/wiki/2/friendships/followers/destroy/en @param theUserThatYouDontLike the userID of the follower which you want to remove. @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForRemoveFollowerUser:(NSString*)theUserThatYouDontLike withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "messages/invite". @discussion Simplifies preparing a request and sending request to send invitation to a bilateral friend of the authenticating user. A successful Open API call will return an NSDictionary of objects which contanis objects representing sender and receiver and other invitation details. You can see more details about this API in http://open.weibo.com/wiki/2/messages/invite @param theUserThatShouldBeYourBilateralFriend the userID of the follower which you want to remove. @param accessToken The token string. @param text The text content in your invitation message. should not be nil. @param url The url in your invitation message. can be nil. @param logoUrl The logoUrl in your invitation message. can be nil. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForInviteBilateralFriend:(NSString*)theUserThatShouldBeYourBilateralFriend withAccessToken:(NSString*)accessToken inviteText:(NSString*)text inviteUrl:(NSString*)url inviteLogoUrl:(NSString*)logoUrl queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /*! @method @abstract Creates a request representing a Open API call to the "users/show". @discussion Simplifies preparing a request and sending request to retrieve user profile by user ID.. A successful Open API call will return a object representing the user profile by user ID. You can see more details about this API in http://open.weibo.com/wiki/2/users/show/en @param aUserID a User ID. @param accessToken The token string. @param otherProperties Any additional properties for the Open API Request. @param queue specify the queue that you want to send request on, if this param is nil, the request will be start on MainQueue( [NSOperationQueue mainQueue] ). @param handler the comletion block which will be executed after received response from Open API server. */ + (WBHttpRequest *)requestForUserProfile:(NSString*)aUserID withAccessToken:(NSString*)accessToken andOtherProperties:(NSDictionary*)otherProperties queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; @end ================================================ FILE: ios/libWeiboSDK/WBHttpRequest.h ================================================ // // WBHttpRequest.h // WeiboSDK // // Created by DannionQiu on 14-9-18. // Copyright (c) 2014年 SINA iOS Team. All rights reserved. // #import #import #pragma mark - WBHttpRequest and WBHttpRequestDelegate @class WBHttpRequest; /** 接收并处理来自微博sdk对于网络请求接口的调用响应 以及openAPI 如inviteFriend、logOutWithToken的请求 */ @protocol WBHttpRequestDelegate /** 收到一个来自微博Http请求的响应 @param response 具体的响应对象 */ @optional - (void)request:(WBHttpRequest *)request didReceiveResponse:(NSURLResponse *)response; /** 收到一个来自微博Http请求失败的响应 @param error 错误信息 */ @optional - (void)request:(WBHttpRequest *)request didFailWithError:(NSError *)error; /** 收到一个来自微博Http请求的网络返回 @param result 请求返回结果 */ @optional - (void)request:(WBHttpRequest *)request didFinishLoadingWithResult:(NSString *)result; /** 收到一个来自微博Http请求的网络返回 @param data 请求返回结果 */ @optional - (void)request:(WBHttpRequest *)request didFinishLoadingWithDataResult:(NSData *)data; /** 收到快速SSO授权的重定向 @param URI */ @optional - (void)request:(WBHttpRequest *)request didReciveRedirectResponseWithURI:(NSURL *)redirectUrl; @end /** 微博封装Http请求的消息结构 */ @interface WBHttpRequest : NSObject { NSURLConnection *connection; NSMutableData *responseData; } /** 用户自定义请求地址URL */ @property (nonatomic, strong) NSString *url; /** 用户自定义请求方式 支持"GET" "POST" */ @property (nonatomic, strong) NSString *httpMethod; /** 用户自定义请求参数字典 */ @property (nonatomic, strong) NSDictionary *params; /** WBHttpRequestDelegate对象,用于接收微博SDK对于发起的接口请求的请求的响应 */ @property (nonatomic, weak) id delegate; /** 用户自定义TAG 用于区分回调Request */ @property (nonatomic, strong) NSString* tag; /** 统一HTTP请求接口 调用此接口后,将发送一个HTTP网络请求 @param url 请求url地址 @param httpMethod 支持"GET" "POST" @param params 向接口传递的参数结构 @param delegate WBHttpRequestDelegate对象,用于接收微博SDK对于发起的接口请求的请求的响应 @param tag 用户自定义TAG,将通过回调WBHttpRequest实例的tag属性返回 */ + (WBHttpRequest *)requestWithURL:(NSString *)url httpMethod:(NSString *)httpMethod params:(NSDictionary *)params delegate:(id)delegate withTag:(NSString *)tag; /** 统一微博Open API HTTP请求接口 调用此接口后,将发送一个HTTP网络请求(用于访问微博open api) @param accessToken 应用获取到的accessToken,用于身份验证 @param url 请求url地址 @param httpMethod 支持"GET" "POST" @param params 向接口传递的参数结构 @param delegate WBHttpRequestDelegate对象,用于接收微博SDK对于发起的接口请求的请求的响应 @param tag 用户自定义TAG,将通过回调WBHttpRequest实例的tag属性返回 */ + (WBHttpRequest *)requestWithAccessToken:(NSString *)accessToken url:(NSString *)url httpMethod:(NSString *)httpMethod params:(NSDictionary *)params delegate:(id)delegate withTag:(NSString *)tag; /** 取消网络请求接口 调用此接口后,将取消当前网络请求,建议同时[WBHttpRequest setDelegate:nil]; 注意:该方法只对使用delegate的request方法有效。无法取消任何使用block的request的网络请求接口。 */ - (void)disconnect; #pragma mark - block extension typedef void (^WBRequestHandler)(WBHttpRequest *httpRequest, id result, NSError *error); /** 统一微博Open API HTTP请求接口 调用此接口后,将发送一个HTTP网络请求(用于访问微博open api) @param url 请求url地址 @param httpMethod 支持"GET" "POST" @param params 向接口传递的参数结构 @param queue 发起请求的NSOperationQueue对象,如queue为nil,则在主线程([NSOperationQueue mainQueue])发起请求。 @param handler 接口请求返回调用的block方法 */ + (WBHttpRequest *)requestWithURL:(NSString *)url httpMethod:(NSString *)httpMethod params:(NSDictionary *)params queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; /** 统一HTTP请求接口 调用此接口后,将发送一个HTTP网络请求 @param url 请求url地址 @param httpMethod 支持"GET" "POST" @param params 向接口传递的参数结构 @param queue 发起请求的NSOperationQueue对象,如queue为nil,则在主线程([NSOperationQueue mainQueue])发起请求。 @param handler 接口请求返回调用的block方法 */ + (WBHttpRequest *)requestWithAccessToken:(NSString *)accessToken url:(NSString *)url httpMethod:(NSString *)httpMethod params:(NSDictionary *)params queue:(NSOperationQueue*)queue withCompletionHandler:(WBRequestHandler)handler; @end ================================================ FILE: ios/libWeiboSDK/WBSDKBasicButton.h ================================================ // // WBSDKBasicButton.h // WeiboSDK // // Created by DannionQiu on 14/10/24. // Copyright (c) 2014年 SINA iOS Team. All rights reserved. // #import @class WBSDKBasicButton; typedef void (^WBSDKButtonHandler)(WBSDKBasicButton *button, BOOL isSuccess, NSDictionary *resultDict); @interface WBSDKBasicButton : UIButton @end ================================================ FILE: ios/libWeiboSDK/WBSDKCommentButton.h ================================================ // // WBSDKCommentButton.h // WeiboSDK // // Created by DannionQiu on 14/10/26. // Copyright (c) 2014年 SINA iOS Team. All rights reserved. // #import "WBSDKBasicButton.h" @interface WBSDKCommentButton : WBSDKBasicButton /** 初始化一个社会化评论按钮 @param frame 按钮的frame值 @param accessToken 用户授权后获取的Token @param keyWord 社会化评论的热点词 @param urlString 社会化评论链接,可传空 @param category 领域ID, 此参数为必选参数。 @param handler 回调函数,当用户点击按钮,进行完与社会化评论组件相关的交互之后,回调的函数。 */ - (id)initWithFrame:(CGRect)frame accessToken:(NSString*)accessToken keyword:(NSString*)keyWord urlString:(NSString*)urlString category:(NSString*)category completionHandler:(WBSDKButtonHandler)handler; @property (nonatomic, strong)NSString* keyWord; @property (nonatomic, strong)NSString* accessToken; @property (nonatomic, strong)NSString* urlString; @property (nonatomic, strong)NSString* category; @end ================================================ FILE: ios/libWeiboSDK/WBSDKRelationshipButton.h ================================================ // // WBSDKRelationshipButton.h // WeiboSDK // // Created by DannionQiu on 14/10/26. // Copyright (c) 2014年 SINA iOS Team. All rights reserved. // #import "WBSDKBasicButton.h" enum { WBSDKRelationshipButtonStateFollow, WBSDKRelationshipButtonStateUnfollow }; typedef NSUInteger WBSDKRelationshipButtonState; @interface WBSDKRelationshipButton : WBSDKBasicButton /** 初始化一个关注组件按钮 @param frame 按钮的frame值 @param accessToken 用户授权后获取的Token @param currentUserID 当前用户的uid值 @param followerUserID 希望当前用户加关注的用户uid值 @param handler 回调函数,当用户点击按钮,进行完关注组件相关的交互之后,回调的函数。 */ - (id)initWithFrame:(CGRect)frame accessToken:(NSString*)accessToken currentUser:(NSString*)currentUserID followUser:(NSString*)followerUserID completionHandler:(WBSDKButtonHandler)handler; @property (nonatomic, strong)NSString* accessToken; @property (nonatomic, strong)NSString* currentUserID; @property (nonatomic, strong)NSString* followUserID; @property (nonatomic, assign)WBSDKRelationshipButtonState currentRelationShip; /** 获取最新的关注状态 该方法会调用OpenApi,获取当前用户与目标用户之间的关注状态,并将按钮的状态改变为正确的状态。 */ - (void)checkCurrentRelationship; @end ================================================ FILE: ios/libWeiboSDK/WeiboSDK.bundle/others/countryList ================================================ {"香港地区":{"code":"00852","rule":{"mcc":["454"]}},"台湾地区":{"code":"00886","rule":{"mcc":["466"]}},"澳门地区":{"code":"00853","rule":{"mcc":["455"]}},"日本":{"code":"0081","rule":{"mcc":["440","441"]}},"韩国":{"code":"0082","rule":{"mcc":["450"]}},"新加坡":{"code":"0065","rule":{"mcc":["525"]}},"马来西亚":{"code":"0060","rule":{"mcc":["502"]}},"美国":{"code":"001","rule":{"mcc":["310","311","316"]}},"加拿大":{"code":"001","rule":{"mcc":["302"]}},"澳大利亚":{"code":"0061","rule":{"mcc":["505"]}},"英国":{"code":"0044","rule":{"mcc":["234"]}},"法国":{"code":"0033","rule":{"mcc":["208"]}},"俄罗斯":{"code":"007","rule":{"mcc":["250"]}},"印度":{"code":"0091","rule":{"mcc":["404"]}},"泰国":{"code":"0066","rule":{"mcc":["520"]}},"德国":{"code":"0049","rule":{"mcc":["262"]}}} ================================================ FILE: ios/libWeiboSDK/WeiboSDK.h ================================================ // // WeiboSDKHeaders.h // WeiboSDKDemo // // Created by Wade Cheng on 4/3/13. // Copyright (c) 2013 SINA iOS Team. All rights reserved. // #import #import #import "WBHttpRequest.h" #import "WBHttpRequest+WeiboUser.h" #import "WBHttpRequest+WeiboShare.h" #import "WBHttpRequest+WeiboToken.h" #import "WBHttpRequest+WeiboGame.h" #import "WBSDKRelationshipButton.h" #import "WBSDKCommentButton.h" typedef NS_ENUM(NSInteger, WeiboSDKResponseStatusCode) { WeiboSDKResponseStatusCodeSuccess = 0,//成功 WeiboSDKResponseStatusCodeUserCancel = -1,//用户取消发送 WeiboSDKResponseStatusCodeSentFail = -2,//发送失败 WeiboSDKResponseStatusCodeAuthDeny = -3,//授权失败 WeiboSDKResponseStatusCodeUserCancelInstall = -4,//用户取消安装微博客户端 WeiboSDKResponseStatusCodePayFail = -5,//支付失败 WeiboSDKResponseStatusCodeShareInSDKFailed = -8,//分享失败 详情见response UserInfo WeiboSDKResponseStatusCodeUnsupport = -99,//不支持的请求 WeiboSDKResponseStatusCodeUnknown = -100, }; @protocol WeiboSDKDelegate; @protocol WBHttpRequestDelegate; @class WBBaseRequest; @class WBBaseResponse; @class WBMessageObject; @class WBImageObject; @class WBBaseMediaObject; @class WBHttpRequest; @class WBOrderObject; /** 微博SDK接口类 */ @interface WeiboSDK : NSObject /** 检查用户是否安装了微博客户端程序 @return 已安装返回YES,未安装返回NO */ + (BOOL)isWeiboAppInstalled; /** 检查用户是否可以通过微博客户端进行分享 @return 可以使用返回YES,不可以使用返回NO */ + (BOOL)isCanShareInWeiboAPP; /** 检查用户是否可以使用微博客户端进行SSO授权 @return 可以使用返回YES,不可以使用返回NO */ + (BOOL)isCanSSOInWeiboApp; /** 打开微博客户端程序 @return 成功打开返回YES,失败返回NO */ + (BOOL)openWeiboApp; /** 获取微博客户端程序的itunes安装地址 @return 微博客户端程序的itunes安装地址 */ + (NSString *)getWeiboAppInstallUrl; /** 获取当前微博客户端程序所支持的SDK最高版本 @return 当前微博客户端程序所支持的SDK最高版本号,返回 nil 表示未安装微博客户端 */ + (NSString *)getWeiboAppSupportMaxSDKVersion __attribute__((deprecated)); /** 获取当前微博SDK的版本号 @return 当前微博SDK的版本号 */ + (NSString *)getSDKVersion; extern NSString * const WeiboSDKGetAidSucessNotification; extern NSString * const WeiboSDKGetAidFailNotification; /** 获取当前微博SDK的aid 返回的aid值可能为 nil ,当值为 nil 时会尝试获取 aid 值。 当获取成功( aid 值变为有效值)时,SDK会发出名为 WeiboSDKGetAidSucessNotification 的通知,通知中带有 aid 值。 当获取失败时,SDK会发出名为 WeiboSDKGetAidFailNotification 的通知,通知中带有 NSError 对象。 @return aid 用于广告的与设备信息相关的标识符 */ + (NSString *)getWeiboAid; /** 向微博客户端程序注册第三方应用 @param appKey 微博开放平台第三方应用appKey @return 注册成功返回YES,失败返回NO */ + (BOOL)registerApp:(NSString *)appKey; /** 处理微博客户端程序通过URL启动第三方应用时传递的数据 需要在 application:openURL:sourceApplication:annotation:或者application:handleOpenURL中调用 @param url 启动第三方应用的URL @param delegate WeiboSDKDelegate对象,用于接收微博触发的消息 @see WeiboSDKDelegate */ + (BOOL)handleOpenURL:(NSURL *)url delegate:(id)delegate; /** 发送请求给微博客户端程序,并切换到微博 请求发送给微博客户端程序之后,微博客户端程序会进行相关的处理,处理完成之后一定会调用 [WeiboSDKDelegate didReceiveWeiboResponse:] 方法将处理结果返回给第三方应用 @param request 具体的发送请求 @see [WeiboSDKDelegate didReceiveWeiboResponse:] @see WBBaseResponse */ + (BOOL)sendRequest:(WBBaseRequest *)request; /** 收到微博客户端程序的请求后,发送对应的应答给微博客户端端程序,并切换到微博 第三方应用收到微博的请求后,异步处理该请求,完成后必须调用该函数将应答返回给微博 @param response 具体的应答内容 @see WBBaseRequest */ + (BOOL)sendResponse:(WBBaseResponse *)response; /** 设置WeiboSDK的调试模式 当开启调试模式时,WeiboSDK会在控制台输出详细的日志信息,开发者可以据此调试自己的程序。默认为 NO @param enabled 开启或关闭WeiboSDK的调试模式 */ + (void)enableDebugMode:(BOOL)enabled; /** 取消授权,登出接口 调用此接口后,token将失效 @param token 第三方应用之前申请的Token @param delegate WBHttpRequestDelegate对象,用于接收微博SDK对于发起的接口请求的请求的响应 @param tag 用户自定义TAG,将通过回调WBHttpRequest实例的tag属性返回 */ + (void)logOutWithToken:(NSString *)token delegate:(id)delegate withTag:(NSString*)tag; /** 邀请好友使用应用 调用此接口后,将发送私信至好友,成功将返回微博标准私信结构 @param data 邀请数据。必须为json字串的形式,必须做URLEncode,采用UTF-8编码。 data参数支持的参数: 参数名称 值的类型 是否必填 说明描述 text string true 要回复的私信文本内容。文本大小必须小于300个汉字。 url string false 邀请点击后跳转链接。默认为当前应用地址。 invite_logo string false 邀请Card展示时的图标地址,大小必须为80px X 80px,仅支持PNG、JPG格式。默认为当前应用logo地址。 @param uid 被邀请人,需为当前用户互粉好友。 @param access_token 第三方应用之前申请的Token @param delegate WBHttpRequestDelegate对象,用于接收微博SDK对于发起的接口请求的请求的响应 @param tag 用户自定义TAG,将通过回调WBHttpRequest实例的tag属性返回 */ + (void)inviteFriend:(NSString* )data withUid:(NSString *)uid withToken:(NSString *)access_token delegate:(id)delegate withTag:(NSString*)tag; /* 第三方调用微博短信注册或者登陆 @param navTitle 为登陆页navigationBar的title,如果为空的话,默认为“验证码登陆” */ + (void)messageRegister:(NSString *)navTitle; @end /** 接收并处理来至微博客户端程序的事件消息 */ @protocol WeiboSDKDelegate /** 收到一个来自微博客户端程序的请求 收到微博的请求后,第三方应用应该按照请求类型进行处理,处理完后必须通过 [WeiboSDK sendResponse:] 将结果回传给微博 @param request 具体的请求对象 */ - (void)didReceiveWeiboRequest:(WBBaseRequest *)request; /** 收到一个来自微博客户端程序的响应 收到微博的响应后,第三方应用可以通过响应类型、响应的数据和 WBBaseResponse.userInfo 中的数据完成自己的功能 @param response 具体的响应对象 */ - (void)didReceiveWeiboResponse:(WBBaseResponse *)response; @end #pragma mark - DataTransferObject and Base Request/Response /** 微博客户端程序和第三方应用之间传输数据信息的基类 */ @interface WBDataTransferObject : NSObject /** 自定义信息字典,用于数据传输过程中存储相关的上下文环境数据 第三方应用给微博客户端程序发送 request 时,可以在 userInfo 中存储请求相关的信息。 @warning userInfo中的数据必须是实现了 `NSCoding` 协议的对象,必须保证能序列化和反序列化 @warning 序列化后的数据不能大于10M */ @property (nonatomic, strong) NSDictionary *userInfo; /** 发送该数据对象的SDK版本号 如果数据对象是自己生成的,则sdkVersion为当前SDK的版本号;如果是接收到的数据对象,则sdkVersion为数据发送方SDK版本号 */ @property (strong, nonatomic, readonly) NSString *sdkVersion; /** 当用户没有安装微博客户端程序时是否提示用户打开微博安装页面 如果设置为YES,当用户未安装微博时会弹出Alert询问用户是否要打开微博App的安装页面。默认为YES */ @property (nonatomic, assign) BOOL shouldOpenWeiboAppInstallPageIfNotInstalled; @end /** 微博SDK所有请求类的基类 */ @interface WBBaseRequest : WBDataTransferObject /** 返回一个 WBBaseRequest 对象 @return 返回一个*自动释放的*WBBaseRequest对象 */ + (id)request; @end /** 微博SDK所有响应类的基类 */ @interface WBBaseResponse : WBDataTransferObject /** 对应的 request 中的自定义信息字典 如果当前 response 是由微博客户端响应给第三方应用的,则 requestUserInfo 中会包含原 request.userInfo 中的所有数据 @see WBBaseRequest.userInfo */ @property (strong, nonatomic, readonly) NSDictionary *requestUserInfo; /** 响应状态码 第三方应用可以通过statusCode判断请求的处理结果 */ @property (nonatomic, assign) WeiboSDKResponseStatusCode statusCode; /** 返回一个 WBBaseResponse 对象 @return 返回一个*自动释放的*WBBaseResponse对象 */ + (id)response; @end #pragma mark - Authorize Request/Response /** 第三方应用向微博客户端请求认证的消息结构 第三方应用向微博客户端申请认证时,需要调用 [WeiboSDK sendRequest:] 函数, 向微博客户端发送一个 WBAuthorizeRequest 的消息结构。 微博客户端处理完后会向第三方应用发送一个结构为 WBAuthorizeResponse 的处理结果。 */ @interface WBAuthorizeRequest : WBBaseRequest /** 微博开放平台第三方应用授权回调页地址,默认为`http://` 参考 http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E#.E5.AE.A2.E6.88.B7.E7.AB.AF.E9.BB.98.E8.AE.A4.E5.9B.9E.E8.B0.83.E9.A1.B5 @warning 必须保证和在微博开放平台应用管理界面配置的“授权回调页”地址一致,如未进行配置则默认为`http://` @warning 不能为空,长度小于1K */ @property (nonatomic, strong) NSString *redirectURI; /** 微博开放平台第三方应用scope,多个scrope用逗号分隔 参考 http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E#scope @warning 长度小于1K */ @property (nonatomic, strong) NSString *scope; /** 当用户没有安装微博客户端或微博客户端过低无法支持SSO的时候是否弹出SDK自带的Webview进行授权 如果设置为YES,当用户没有安装微博客户端或微博客户端过低无法支持SSO的时候会自动弹出SDK自带的Webview进行授权。 如果设置为NO,会根据 shouldOpenWeiboAppInstallPageIfNotInstalled 属性判断是否弹出安装/更新微博的对话框 默认为YES */ @property (nonatomic, assign) BOOL shouldShowWebViewForAuthIfCannotSSO; @end /** 微博客户端处理完第三方应用的认证申请后向第三方应用回送的处理结果 WBAuthorizeResponse 结构中仅包含常用的 userID 、accessToken 和 expirationDate 信息,其他的认证信息(比如部分应用可以获取的 refresh_token 信息)会统一存放到 userInfo 中 */ @interface WBAuthorizeResponse : WBBaseResponse /** 用户ID */ @property (nonatomic, strong) NSString *userID; /** 认证口令 */ @property (nonatomic, strong) NSString *accessToken; /** 认证过期时间 */ @property (nonatomic, strong) NSDate *expirationDate; /** 当认证口令过期时用于换取认证口令的更新口令 */ @property (nonatomic, strong) NSString *refreshToken; @end #pragma mark - ProvideMessageForWeibo Request/Response /** 微博客户端向第三方程序请求提供内容的消息结构 */ @interface WBProvideMessageForWeiboRequest : WBBaseRequest @end /** 微博客户端向第三方应用请求提供内容,第三方应用向微博客户端返回的消息结构 */ @interface WBProvideMessageForWeiboResponse : WBBaseResponse /** 提供给微博客户端的消息 */ @property (nonatomic, strong) WBMessageObject *message; /** 返回一个 WBProvideMessageForWeiboResponse 对象 @param message 需要回送给微博客户端程序的消息对象 @return 返回一个*自动释放的*WBProvideMessageForWeiboResponse对象 */ + (id)responseWithMessage:(WBMessageObject *)message; @end #pragma mark - SendMessageToWeibo Request/Response /** 第三方应用发送消息至微博客户端程序的消息结构体 */ @interface WBSendMessageToWeiboRequest : WBBaseRequest /** 发送给微博客户端的消息 */ @property (nonatomic, strong) WBMessageObject *message; /** 返回一个 WBSendMessageToWeiboRequest 对象 此方法生成对象被[WeiboSDK sendRequest:]会唤起微博客户端的发布器进行分享,如果未安装微博客户端或客户端版本太低 会根据 shouldOpenWeiboAppInstallPageIfNotInstalled 属性判断是否弹出安装/更新微博的对话框 @param message 需要发送给微博客户端的消息对象 @return 返回一个*自动释放的*WBSendMessageToWeiboRequest对象 */ + (id)requestWithMessage:(WBMessageObject *)message; /** 返回一个 WBSendMessageToWeiboRequest 对象 当用户安装了可以支持微博客户端內分享的微博客户端时,会自动唤起微博并分享 当用户没有安装微博客户端或微博客户端过低无法支持通过客户端內分享的时候会自动唤起SDK內微博发布器 @param message 需要发送给微博的消息对象 @param authRequest 授权相关信息,与access_token二者至少有一个不为空,当access_token为空并且需要弹出SDK內发布器时会通过此信息先进行授权后再分享 @param access_token 第三方应用之前申请的Token,当此值不为空并且无法通过客户端分享的时候,会使用此token进行分享。 @return 返回一个*自动释放的*WBSendMessageToWeiboRequest对象 */ + (id)requestWithMessage:(WBMessageObject *)message authInfo:(WBAuthorizeRequest *)authRequest access_token:(NSString *)access_token; @end /** WBSendMessageToWeiboResponse */ @interface WBSendMessageToWeiboResponse : WBBaseResponse /** 可能在分享过程中用户进行了授权操作,当此值不为空时,为用户相应授权信息 */ @property (nonatomic,strong) WBAuthorizeResponse *authResponse; @end #pragma mark - AppRecomend Request/Response /** 第三方应用私信好友推荐app的请求 */ @interface WBSDKAppRecommendRequest : WBBaseRequest /** 返回一个 WBSDKAppRecommendRequest 对象 @param uids 为推荐的好友列表,为空时跳转到用户自选的页面 @param access_token 第三方应用之前申请的Token,当此值不为空并且无法通过客户端分享的时候,会使用此token私信。 @return 返回一个*自动释放的*WBSDKAppRecommendRequest对象 */ + (id)requestWithUIDs:(NSArray *)uids access_token:(NSString *)access_token; /** 私信对象列表 */ @property (nonatomic, strong) NSArray* uids; /** 用于认证的Token */ @property (nonatomic, strong) NSString *access_token; @end /** 第三方应用私信好友推荐app的响应 WBSDKAppRecommendResponse 结构中仅包含常用的 userID 、accessToken 和 expirationDate 信息,其他的认证信息(比如部分应用可以获取的 refresh_token 信息)会统一存放到 userInfo 中 */ @interface WBSDKAppRecommendResponse : WBBaseResponse @property (nonatomic,strong) WBAuthorizeResponse *authResponse; /** 用户ID */ @property (nonatomic, strong) NSString *userID; /** 认证口令 */ @property (nonatomic, strong) NSString *accessToken; /** 认证过期时间 */ @property (nonatomic, strong) NSDate *expirationDate; /** 当认证口令过期时用于换取认证口令的更新口令 */ @property (nonatomic, strong) NSString *refreshToken; @end #pragma mark - Payment Request/Response /** 第三方应用发送消息至微博客户端程序的消息结构体 */ @interface WBPaymentRequest : WBBaseRequest /** 发送给微博客户端的订单 */ @property (nonatomic, strong) WBOrderObject *order; /** 返回一个 WBPaymentRequest 对象 @param message 需要发送给微博客户端程序的消息对象 @return 返回一个*自动释放的*WBSendMessageToWeiboRequest对象 */ + (id)requestWithOrder:(WBOrderObject *)order; @end /** WBPaymentResponse */ @interface WBPaymentResponse : WBBaseResponse /** 支付返回状态码 */ @property (nonatomic, strong) NSString *payStatusCode; /** 支付返回状态信息 */ @property (nonatomic, strong) NSString *payStatusMessage; @end #pragma mark - MessageObject / ImageObject /** 微博客户端程序和第三方应用之间传递的消息结构 一个消息结构由三部分组成:文字、图片和多媒体数据。三部分内容中至少有一项不为空,图片和多媒体数据不能共存。 */ @interface WBMessageObject : NSObject /** 消息的文本内容 @warning 长度小于140个汉字 */ @property (nonatomic, strong) NSString *text; /** 消息的图片内容 @see WBImageObject */ @property (nonatomic, strong) WBImageObject *imageObject; /** 消息的多媒体内容 @see WBBaseMediaObject */ @property (nonatomic, strong) WBBaseMediaObject *mediaObject; /** 返回一个 WBMessageObject 对象 @return 返回一个*自动释放的*WBMessageObject对象 */ + (id)message; @end /** 消息中包含的图片数据对象 */ @interface WBImageObject : NSObject /** 图片真实数据内容 @warning 大小不能超过10M */ @property (nonatomic, strong) NSData *imageData; /** 返回一个 WBImageObject 对象 @return 返回一个*自动释放的*WBImageObject对象 */ + (id)object; /** 返回一个 UIImage 对象 @return 返回一个*自动释放的*UIImage对象 */ - (UIImage *)image; @end #pragma mark - Message Media Objects /** 消息中包含的多媒体数据对象基类 */ @interface WBBaseMediaObject : NSObject /** 对象唯一ID,用于唯一标识一个多媒体内容 当第三方应用分享多媒体内容到微博时,应该将此参数设置为被分享的内容在自己的系统中的唯一标识 @warning 不能为空,长度小于255 */ @property (nonatomic, strong) NSString *objectID; /** 多媒体内容标题 @warning 不能为空且长度小于1k */ @property (nonatomic, strong) NSString *title; /** 多媒体内容描述 @warning 长度小于1k */ @property (nonatomic, strong) NSString *description; /** 多媒体内容缩略图 @warning 大小小于32k */ @property (nonatomic, strong) NSData *thumbnailData; /** 点击多媒体内容之后呼起第三方应用特定页面的scheme @warning 长度小于255 */ @property (nonatomic, strong) NSString *scheme; /** 返回一个 WBBaseMediaObject 对象 @return 返回一个*自动释放的*WBBaseMediaObject对象 */ + (id)object; @end #pragma mark - Message Video Objects /** 消息中包含的视频数据对象 */ @interface WBVideoObject : WBBaseMediaObject /** 视频网页的url @warning 不能为空且长度不能超过255 */ @property (nonatomic, strong) NSString *videoUrl; /** 视频lowband网页的url @warning 长度不能超过255 */ @property (nonatomic, strong) NSString *videoLowBandUrl; /** 视频数据流url @warning 长度不能超过255 */ @property (nonatomic, strong) NSString *videoStreamUrl; /** 视频lowband数据流url @warning 长度不能超过255 */ @property (nonatomic, strong) NSString *videoLowBandStreamUrl; @end #pragma mark - Message Music Objects /** 消息中包含的音乐数据对象 */ @interface WBMusicObject : WBBaseMediaObject /** 音乐网页url地址 @warning 不能为空且长度不能超过255 */ @property (nonatomic, strong) NSString *musicUrl; /** 音乐lowband网页url地址 @warning 长度不能超过255 */ @property (nonatomic, strong) NSString *musicLowBandUrl; /** 音乐数据流url @warning 长度不能超过255 */ @property (nonatomic, strong) NSString *musicStreamUrl; /** 音乐lowband数据流url @warning 长度不能超过255 */ @property (nonatomic, strong) NSString *musicLowBandStreamUrl; @end #pragma mark - Message WebPage Objects /** 消息中包含的网页数据对象 */ @interface WBWebpageObject : WBBaseMediaObject /** 网页的url地址 @warning 不能为空且长度不能超过255 */ @property (nonatomic, strong) NSString *webpageUrl; @end #pragma mark - OrderObject /** 微博客户端程序和第三方应用之间传递的订单结构 */ @interface WBOrderObject : NSObject /** 订单编号 */ @property (nonatomic, strong) NSString *orderString; /** 返回一个 WBOrderObject 对象 @return 返回一个*自动释放的*WBOrderObject对象 */ + (id)order; @end ================================================ FILE: ios/libWeiboSDK/WeiboUser.h ================================================ // // WeiboUser.h // WeiboSDK // // Created by DannionQiu on 14-9-23. // Copyright (c) 2014年 SINA iOS Team. All rights reserved. // #import /*@ You can get the latest WeiboUser field description on http://open.weibo.com/wiki/2/friendships/friends/en . */ @interface WeiboUser : NSObject - (instancetype)initWithDictionary:(NSDictionary*)paraDict; + (instancetype)userWithDictionary:(NSDictionary*)paraDict; // Validate the dictionary to be converted. + (BOOL)isValidForDictionary:(NSDictionary *)dict; - (BOOL)updateWithDictionary:(NSDictionary*)paraDict; @property(readwrite, strong, nonatomic) NSString* userID; @property(readwrite, strong, nonatomic) NSString* userClass; @property(readwrite, strong, nonatomic) NSString* screenName; @property(readwrite, strong, nonatomic) NSString* name; @property(readwrite, strong, nonatomic) NSString* province; @property(readwrite, strong, nonatomic) NSString* city; @property(readwrite, strong, nonatomic) NSString* location; @property(readwrite, strong, nonatomic) NSString* userDescription; @property(readwrite, strong, nonatomic) NSString* url; @property(readwrite, strong, nonatomic) NSString* profileImageUrl; @property(readwrite, strong, nonatomic) NSString* coverImageUrl; @property(readwrite, strong, nonatomic) NSString* coverImageForPhoneUrl; @property(readwrite, strong, nonatomic) NSString* profileUrl; @property(readwrite, strong, nonatomic) NSString* userDomain; @property(readwrite, strong, nonatomic) NSString* weihao; @property(readwrite, strong, nonatomic) NSString* gender; @property(readwrite, strong, nonatomic) NSString* followersCount; @property(readwrite, strong, nonatomic) NSString* friendsCount; @property(readwrite, strong, nonatomic) NSString* pageFriendsCount; @property(readwrite, strong, nonatomic) NSString* statusesCount; @property(readwrite, strong, nonatomic) NSString* favouritesCount; @property(readwrite, strong, nonatomic) NSString* createdTime; @property(readwrite, assign, nonatomic) BOOL isFollowingMe; @property(readwrite, assign, nonatomic) BOOL isFollowingByMe; @property(readwrite, assign, nonatomic) BOOL isAllowAllActMsg; @property(readwrite, assign, nonatomic) BOOL isAllowAllComment; @property(readwrite, assign, nonatomic) BOOL isGeoEnabled; @property(readwrite, assign, nonatomic) BOOL isVerified; @property(readwrite, strong, nonatomic) NSString* verifiedType; @property(readwrite, strong, nonatomic) NSString* remark; @property(readwrite, strong, nonatomic) NSString* statusID; @property(readwrite, strong, nonatomic) NSString* ptype; @property(readwrite, strong, nonatomic) NSString* avatarLargeUrl; @property(readwrite, strong, nonatomic) NSString* avatarHDUrl; @property(readwrite, strong, nonatomic) NSString* verifiedReason; @property(readwrite, strong, nonatomic) NSString* verifiedTrade; @property(readwrite, strong, nonatomic) NSString* verifiedReasonUrl; @property(readwrite, strong, nonatomic) NSString* verifiedSource; @property(readwrite, strong, nonatomic) NSString* verifiedSourceUrl; @property(readwrite, strong, nonatomic) NSString* verifiedState; @property(readwrite, strong, nonatomic) NSString* verifiedLevel; @property(readwrite, strong, nonatomic) NSString* onlineStatus; @property(readwrite, strong, nonatomic) NSString* biFollowersCount; @property(readwrite, strong, nonatomic) NSString* language; @property(readwrite, strong, nonatomic) NSString* star; @property(readwrite, strong, nonatomic) NSString* mbtype; @property(readwrite, strong, nonatomic) NSString* mbrank; @property(readwrite, strong, nonatomic) NSString* block_word; @property(readwrite, strong, nonatomic) NSString* block_app; @property(readwrite, strong, nonatomic) NSString* credit_score; @property(readwrite, strong, nonatomic) NSDictionary* originParaDict; @end ================================================ FILE: ios/libWeiboSDK/libWeiboSDK.a ================================================ [File too large to display: 23.8 MB] ================================================ FILE: package.json ================================================ { "name": "react-native-weibo", "version": "3.0.4", "description": "新浪微博登录、分享模块", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", "url": "git+https://github.com/reactnativecn/react-native-weibo.git" }, "keywords": [ "react-native", "ios", "android", "weibo", "sina", "share", "login" ], "author": "lvbingru", "license": "ISC", "bugs": { "url": "https://github.com/reactnativecn/react-native-weibo/issues" }, "homepage": "https://github.com/reactnativecn/react-native-weibo#readme", "dependencies": { "es6-promisify": "^3.0.0" } }