├── .gitignore ├── README.md ├── android ├── .gitignore ├── .npmignore ├── build.gradle ├── libs │ ├── arm64-v8a │ │ └── libweibosdkcore.so │ ├── armeabi-v7a │ │ └── libweibosdkcore.so │ ├── armeabi │ │ └── libweibosdkcore.so │ ├── mips │ │ └── libweibosdkcore.so │ ├── mips64 │ │ └── libweibosdkcore.so │ ├── weiboSDKCore_3.1.2.jar │ ├── x86 │ │ └── libweibosdkcore.so │ └── x86_64 │ │ └── libweibosdkcore.so ├── 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.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ └── lvbingru.xcuserdatad │ │ └── xcschemes │ │ └── RCTWeiboAPI.xcscheme ├── RCTWeiboAPI │ ├── RCTWeiboAPI.h │ └── RCTWeiboAPI.m └── libWeiboSDK │ ├── WBHttpRequest+WeiboGame.h │ ├── WBHttpRequest+WeiboShare.h │ ├── WBHttpRequest+WeiboToken.h │ ├── WBHttpRequest+WeiboUser.h │ ├── WBHttpRequest.h │ ├── WBSDKBasicButton.h │ ├── WBSDKCommentButton.h │ ├── WBSDKRelationshipButton.h │ ├── WeiboSDK.bundle │ ├── images │ │ ├── alert_error_icon@2x.png │ │ ├── alert_success_icon@2x.png │ │ ├── close.png │ │ ├── close@2x.png │ │ ├── common_button_big_blue@2x.png │ │ ├── common_button_big_blue_disable@2x.png │ │ ├── common_button_big_blue_highlighted@2x.png │ │ ├── common_button_white.png │ │ ├── common_button_white@2x.png │ │ ├── common_button_white_highlighted.png │ │ ├── common_button_white_highlighted@2x.png │ │ ├── common_icon_arrow@2x.png │ │ ├── compose_keyboardbutton_background.png │ │ ├── compose_keyboardbutton_background@2x.png │ │ ├── compose_toolbar_background.png │ │ ├── compose_toolbar_background@2x.png │ │ ├── empty_failed.png │ │ ├── empty_failed@2x.png │ │ ├── login_background@2x.png │ │ ├── login_country_background@2x.png │ │ ├── login_country_background_highlighted@2x.png │ │ ├── navigationbar_background.png │ │ ├── navigationbar_background@2x.png │ │ ├── navigationbar_background_os7.png │ │ ├── navigationbar_background_os7@2x.png │ │ ├── progresshud_background@2x.png │ │ ├── sdk_weibo_logo.png │ │ ├── sdk_weibo_logo@2x.png │ │ ├── sdk_weibo_logo@3x.png │ │ ├── timeline_relationship_icon_addattention.png │ │ ├── timeline_relationship_icon_addattention@2x.png │ │ ├── timeline_relationship_icon_addattention@3x.png │ │ ├── timeline_relationship_icon_attention.png │ │ ├── timeline_relationship_icon_attention@2x.png │ │ ├── timeline_relationship_icon_attention@3x.png │ │ ├── verify_code_button@2x.png │ │ ├── verify_code_button@3x.png │ │ ├── verify_code_button_highlighted@2x.png │ │ └── verify_code_button_highlighted@3x.png │ └── others │ │ ├── countryList │ │ └── mfp.cer │ ├── WeiboSDK.h │ ├── WeiboUser.h │ └── libWeiboSDK.a └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-weibo 2 | 3 | React Native的新浪微博登录插件, react-native版本需要0.17.0及以上 4 | ## 如何安装 5 | 6 | ### 1.首先安装npm包 7 | 8 | ```bash 9 | npm install react-native-weibo --save 10 | ``` 11 | 12 | ### 2.link 13 | #### 自动link方法 14 | 15 | ```bash 16 | react-native link 17 | ``` 18 | 19 | #### 手动link~(如果不能够自动link) 20 | #####ios 21 | a.打开XCode's工程中, 右键点击Libraries文件夹 ➜ Add Files to <...> 22 | b.去node_modules ➜ react-native-weibo ➜ ios ➜ 选择 RCTWeiboAPI.xcodeproj 23 | c.在工程Build Phases ➜ Link Binary With Libraries中添加libRCTWeiboAPI.a 24 | 25 | #####Android 26 | 27 | ``` 28 | // file: android/settings.gradle 29 | ... 30 | 31 | include ':react-native-weibo' 32 | project(':react-native-weibo').projectDir = new File(settingsDir, '../node_modules/react-native-weibo/android') 33 | ``` 34 | 35 | ``` 36 | // file: android/app/build.gradle 37 | ... 38 | 39 | dependencies { 40 | ... 41 | compile project(':react-native-weibo') 42 | } 43 | ``` 44 | 45 | `android/app/src/main/java/<你的包名>/MainApplication.java`中添加如下两行: 46 | 47 | ```java 48 | ... 49 | import cn.reactnative.modules.weibo.WeiboPackage; // 在public class MainApplication之前import 50 | 51 | public class MainApplication extends Application implements ReactApplication { 52 | 53 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 54 | @Override 55 | protected boolean getUseDeveloperSupport() { 56 | return BuildConfig.DEBUG; 57 | } 58 | 59 | @Override 60 | protected List getPackages() { 61 | return Arrays.asList( 62 |          new WeiboPackage(), // 然后添加这一行 63 | new MainReactPackage() 64 | ); 65 | } 66 | }; 67 | 68 | @Override 69 | public ReactNativeHost getReactNativeHost() { 70 | return mReactNativeHost; 71 | } 72 | } 73 | ``` 74 | 75 | ### 3.工程配置 76 | #### ios配置 77 | 将`node_modules/react-native-weibo/ios/libWeiboSDK/WeiboSDK.bundle`加入到工程中(必须,很重要,不然登录的时候会crash) 78 | 79 | 在工程target的`Build Phases->Link Binary with Libraries`中加入`libRCTWeiboAPI.a、libsqlite3.tbd、libz.tbd、ImageIO.framework、SystemConfiguration.framework、Security.framework、CoreTelephony.framework、CoreText.framework` 80 | 81 | 82 | 在`Info->URL Types` 中增加QQ的scheme: `Identifier` 设置为`sina`, `URL Schemes` 设置为你注册的微博开发者账号中的APPID,需要加前缀`wb`,例如`wb1915346979` 83 | 84 | 在你工程的`AppDelegate.m`文件中添加如下代码: 85 | 86 | ``` 87 | #import "../Libraries/LinkingIOS/RCTLinkingManager.h" 88 | 89 | 90 | - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { 91 | return [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; 92 | } 93 | 94 | ``` 95 | 96 | ##### iOS9的适配问题 97 | 98 | 由于iOS9的发布影响了微博SDK与应用的集成方式,为了确保好的应用体验,我们需要采取如下措施: 99 | ##### a.对传输安全的支持 100 | 在iOS9系统中,默认需要为每次网络传输建立SSL。解决这个问题: 101 | 102 | - 将NSAllowsArbitraryLoads属性设置为YES,并添加到你应用的plist中 103 | - 104 | NSAppTransportSecurity 105 | 106 | NSAllowsArbitraryLoads 107 | 108 | 109 | 110 | ###### b.对应用跳转的支持 111 | 如果你需要用到微博的相关功能,如登陆,分享等。并且需要实现跳转到微博的功能,在iOS9系统中就需要在你的app的plist中添加下列键值对。否则在canOpenURL函数执行时,就会返回NO。了解详情请至[https://developer.apple.com/videos/wwdc/2015/?id=703](https://developer.apple.com/videos/wwdc/2015/?id=703) 112 | 113 | - 114 | LSApplicationQueriesSchemes 115 | 116 | sinaweibohd 117 | sinaweibo 118 | weibosdk 119 | weibosdk2.5 120 | 121 | 122 | 123 | #### Android 124 | 125 | 在`android/app/build.gradle`里,defaultConfig栏目下添加如下代码: 126 | 127 | ``` 128 | manifestPlaceholders = [ 129 | WB_APPID: "微博的APPID" //在此修改微博APPID 130 | ] 131 | ``` 132 | 133 | 如果react-native版本<0.18.0,确保你的MainActivity.java中有`onActivityResult`的实现: 134 | 135 | ```java 136 | private ReactInstanceManager mReactInstanceManager; 137 | @Override 138 | public void onActivityResult(int requestCode, int resultCode, Intent data){ 139 | super.onActivityResult(requestCode, resultCode, data); 140 | mReactInstanceManager.onActivityResult(requestCode, resultCode, data); 141 | } 142 | ``` 143 | 144 | ## 如何使用 145 | 146 | ### 引入包 147 | 148 | ``` 149 | import * as WeiboAPI from 'react-native-weibo'; 150 | ``` 151 | 152 | ### API 153 | 154 | #### WeiboAPI.login(config) 155 | 156 | ```javascript 157 | // 登录参数 158 | config : { 159 | scope: 权限设置, // 默认 'all' 160 | redirectURI: 重定向地址, // 默认 'https://api.weibo.com/oauth2/default.html'(必须和sina微博开放平台中应用高级设置中的redirectURI设置的一致,不然会登录失败) 161 | } 162 | ``` 163 | 164 | 返回一个`Promise`对象。成功时的回调为一个类似这样的对象: 165 | 166 | ```javascript 167 | { 168 | "accessToken": "2.005e3HMBzh7eFCca6a3854060GQFJf", 169 | "userID": "1098604232" 170 | "expirationDate": "1452884401084.538" 171 | "refreshToken": "2.005e3HMBzh8eFC3db19a18bb00pvbp" 172 | } 173 | ``` 174 | 175 | #### WeiboAPI.share(data) 176 | 177 | 分享到微博 178 | 179 | ```javascript 180 | // 分享文字 181 | { 182 | type: 'text', 183 | text: 文字内容, 184 | } 185 | ``` 186 | 187 | ```javascript 188 | // 分享图片 189 | { 190 | type: 'image', 191 | text: 文字内容, 192 | imageUrl: 图片地址 193 | } 194 | ``` 195 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /android/.npmignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 16 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | sourceSets.main { 20 | jniLibs.srcDirs = ['libs'] 21 | } 22 | } 23 | 24 | dependencies { 25 | compile 'com.facebook.react:react-native:+' 26 | compile files('libs/weiboSDKCore_3.1.2.jar') 27 | } 28 | -------------------------------------------------------------------------------- /android/libs/arm64-v8a/libweibosdkcore.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/android/libs/arm64-v8a/libweibosdkcore.so -------------------------------------------------------------------------------- /android/libs/armeabi-v7a/libweibosdkcore.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/android/libs/armeabi-v7a/libweibosdkcore.so -------------------------------------------------------------------------------- /android/libs/armeabi/libweibosdkcore.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/android/libs/armeabi/libweibosdkcore.so -------------------------------------------------------------------------------- /android/libs/mips/libweibosdkcore.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/android/libs/mips/libweibosdkcore.so -------------------------------------------------------------------------------- /android/libs/mips64/libweibosdkcore.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/android/libs/mips64/libweibosdkcore.so -------------------------------------------------------------------------------- /android/libs/weiboSDKCore_3.1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/android/libs/weiboSDKCore_3.1.2.jar -------------------------------------------------------------------------------- /android/libs/x86/libweibosdkcore.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/android/libs/x86/libweibosdkcore.so -------------------------------------------------------------------------------- /android/libs/x86_64/libweibosdkcore.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/android/libs/x86_64/libweibosdkcore.so -------------------------------------------------------------------------------- /android/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/lvbingru/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /android/src/androidTest/java/cn/reactnative/modules/weibo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package cn.reactnative.modules.weibo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 17 | 18 | 20 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /android/src/main/java/cn/reactnative/modules/weibo/WeiboModule.java: -------------------------------------------------------------------------------- 1 | package cn.reactnative.modules.weibo; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.pm.ApplicationInfo; 7 | import android.content.pm.PackageManager; 8 | import android.graphics.Bitmap; 9 | import android.graphics.Canvas; 10 | import android.graphics.PixelFormat; 11 | import android.graphics.drawable.BitmapDrawable; 12 | import android.graphics.drawable.Drawable; 13 | import android.graphics.drawable.NinePatchDrawable; 14 | import android.net.Uri; 15 | import android.os.Bundle; 16 | import android.util.Log; 17 | 18 | import com.facebook.common.executors.UiThreadImmediateExecutorService; 19 | import com.facebook.common.internal.Preconditions; 20 | import com.facebook.common.references.CloseableReference; 21 | import com.facebook.common.util.UriUtil; 22 | import com.facebook.datasource.BaseDataSubscriber; 23 | import com.facebook.datasource.DataSource; 24 | import com.facebook.datasource.DataSubscriber; 25 | import com.facebook.drawee.backends.pipeline.Fresco; 26 | import com.facebook.drawee.drawable.OrientedDrawable; 27 | import com.facebook.imagepipeline.common.ResizeOptions; 28 | import com.facebook.imagepipeline.core.ImagePipeline; 29 | import com.facebook.imagepipeline.image.CloseableImage; 30 | import com.facebook.imagepipeline.image.CloseableStaticBitmap; 31 | import com.facebook.imagepipeline.image.EncodedImage; 32 | import com.facebook.imagepipeline.request.ImageRequest; 33 | import com.facebook.imagepipeline.request.ImageRequestBuilder; 34 | import com.facebook.react.bridge.ActivityEventListener; 35 | import com.facebook.react.bridge.Arguments; 36 | import com.facebook.react.bridge.Callback; 37 | import com.facebook.react.bridge.ReactApplicationContext; 38 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 39 | import com.facebook.react.bridge.ReactMethod; 40 | import com.facebook.react.bridge.ReadableMap; 41 | import com.facebook.react.bridge.WritableMap; 42 | import com.facebook.react.modules.core.RCTNativeAppEventEmitter; 43 | import com.sina.weibo.sdk.api.ImageObject; 44 | import com.sina.weibo.sdk.api.MusicObject; 45 | import com.sina.weibo.sdk.api.TextObject; 46 | import com.sina.weibo.sdk.api.VideoObject; 47 | import com.sina.weibo.sdk.api.WebpageObject; 48 | import com.sina.weibo.sdk.api.WeiboMultiMessage; 49 | import com.sina.weibo.sdk.api.share.BaseResponse; 50 | import com.sina.weibo.sdk.api.share.IWeiboHandler; 51 | import com.sina.weibo.sdk.api.share.IWeiboShareAPI; 52 | import com.sina.weibo.sdk.api.share.SendMultiMessageToWeiboRequest; 53 | import com.sina.weibo.sdk.api.share.WeiboShareSDK; 54 | import com.sina.weibo.sdk.auth.AuthInfo; 55 | import com.sina.weibo.sdk.auth.Oauth2AccessToken; 56 | import com.sina.weibo.sdk.auth.WeiboAuthListener; 57 | import com.sina.weibo.sdk.auth.sso.SsoHandler; 58 | import com.sina.weibo.sdk.exception.WeiboException; 59 | 60 | import java.util.Date; 61 | 62 | import javax.annotation.Nullable; 63 | 64 | /** 65 | * Created by lvbingru on 12/22/15. 66 | */ 67 | public class WeiboModule extends ReactContextBaseJavaModule implements ActivityEventListener { 68 | 69 | public WeiboModule(ReactApplicationContext reactContext) { 70 | super(reactContext); 71 | ApplicationInfo appInfo = null; 72 | try { 73 | appInfo = reactContext.getPackageManager().getApplicationInfo(reactContext.getPackageName(), PackageManager.GET_META_DATA); 74 | } catch (PackageManager.NameNotFoundException e) { 75 | throw new Error(e); 76 | } 77 | if (!appInfo.metaData.containsKey("WB_APPID")){ 78 | throw new Error("meta-data WB_APPID not found in AndroidManifest.xml"); 79 | } 80 | this.appId = appInfo.metaData.get("WB_APPID").toString(); 81 | this.appId = this.appId.substring(2); 82 | 83 | } 84 | 85 | private static final String RCTWBEventName = "Weibo_Resp"; 86 | 87 | private SsoHandler mSinaSsoHandler; 88 | private IWeiboShareAPI mSinaShareAPI; 89 | private String appId; 90 | 91 | private static final String RCTWBShareTypeNews = "news"; 92 | private static final String RCTWBShareTypeImage = "image"; 93 | private static final String RCTWBShareTypeText = "text"; 94 | private static final String RCTWBShareTypeVideo = "video"; 95 | private static final String RCTWBShareTypeAudio = "audio"; 96 | 97 | private static final String RCTWBShareType = "type"; 98 | private static final String RCTWBShareText = "text"; 99 | private static final String RCTWBShareTitle = "title"; 100 | private static final String RCTWBShareDescription = "description"; 101 | private static final String RCTWBShareWebpageUrl = "webpageUrl"; 102 | private static final String RCTWBShareImageUrl = "imageUrl"; 103 | private static final String RCTWBShareAccessToken = "accessToken"; 104 | 105 | private static WeiboModule gModule = null; 106 | 107 | @Override 108 | public void initialize() { 109 | super.initialize(); 110 | gModule = this; 111 | getReactApplicationContext().addActivityEventListener(this); 112 | } 113 | 114 | @Override 115 | public void onCatalystInstanceDestroy() { 116 | super.onCatalystInstanceDestroy(); 117 | gModule = null; 118 | getReactApplicationContext().removeActivityEventListener(this); 119 | } 120 | 121 | @Override 122 | public String getName() { 123 | return "RCTWeiboAPI"; 124 | } 125 | 126 | private IWeiboShareAPI registerShare() { 127 | if (mSinaShareAPI == null) { 128 | mSinaShareAPI = WeiboShareSDK.createWeiboAPI(getReactApplicationContext(), this.appId); 129 | mSinaShareAPI.registerApp(); 130 | } 131 | return mSinaShareAPI; 132 | } 133 | 134 | 135 | @ReactMethod 136 | public void login(final ReadableMap config, final Callback callback){ 137 | 138 | AuthInfo sinaAuthInfo = this._genAuthInfo(config); 139 | mSinaSsoHandler = new SsoHandler(getCurrentActivity(), sinaAuthInfo); 140 | mSinaSsoHandler.authorize(this.genWeiboAuthListener()); 141 | callback.invoke(); 142 | } 143 | 144 | @ReactMethod 145 | public void shareToWeibo(final ReadableMap data, Callback callback){ 146 | 147 | if (data.hasKey(RCTWBShareImageUrl)) { 148 | String imageUrl = data.getString(RCTWBShareImageUrl); 149 | DataSubscriber> dataSubscriber = 150 | new BaseDataSubscriber>() { 151 | @Override 152 | public void onNewResultImpl(DataSource> dataSource) { 153 | // isFinished must be obtained before image, otherwise we might set intermediate result 154 | // as final image. 155 | boolean isFinished = dataSource.isFinished(); 156 | // float progress = dataSource.getProgress(); 157 | CloseableReference image = dataSource.getResult(); 158 | if (image != null) { 159 | Drawable drawable = _createDrawable(image); 160 | Bitmap bitmap = _drawable2Bitmap(drawable); 161 | _share(data, bitmap); 162 | } else if (isFinished) { 163 | _share(data, null); 164 | } 165 | dataSource.close(); 166 | } 167 | @Override 168 | public void onFailureImpl(DataSource> dataSource) { 169 | dataSource.close(); 170 | _share(data, null); 171 | } 172 | 173 | @Override 174 | public void onProgressUpdate(DataSource> dataSource) { 175 | } 176 | }; 177 | ResizeOptions resizeOptions = null; 178 | if (!data.hasKey(RCTWBShareType) || !data.getString(RCTWBShareType).equals(RCTWBShareTypeImage)) { 179 | resizeOptions = new ResizeOptions(80, 80); 180 | } 181 | 182 | this._downloadImage(imageUrl, resizeOptions, dataSubscriber); 183 | } 184 | else { 185 | this._share(data, null); 186 | } 187 | 188 | callback.invoke(); 189 | } 190 | 191 | public void onActivityResult(int requestCode, int resultCode, Intent data) { 192 | if (mSinaSsoHandler != null) { 193 | mSinaSsoHandler.authorizeCallBack(requestCode, resultCode, data); 194 | mSinaSsoHandler = null; 195 | } 196 | } 197 | 198 | public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data){ 199 | this.onActivityResult(requestCode, resultCode, data); 200 | } 201 | 202 | public void onNewIntent(Intent intent){ 203 | 204 | } 205 | 206 | WeiboAuthListener genWeiboAuthListener() { 207 | return new WeiboAuthListener() { 208 | @Override 209 | public void onComplete(Bundle bundle) { 210 | 211 | final Oauth2AccessToken token = Oauth2AccessToken.parseAccessToken(bundle); 212 | WritableMap event = Arguments.createMap(); 213 | if (token.isSessionValid()) { 214 | event.putString("accessToken", token.getToken()); 215 | event.putDouble("expirationDate", token.getExpiresTime()); 216 | event.putString("userID", token.getUid()); 217 | event.putString("refreshToken", token.getRefreshToken()); 218 | event.putInt("errCode", 0); 219 | } else { 220 | // String code = bundle.getString("code", ""); 221 | event.putInt("errCode", -1); 222 | event.putString("errMsg", "token invalid"); 223 | } 224 | event.putString("type", "WBAuthorizeResponse"); 225 | getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class).emit(RCTWBEventName, event); 226 | } 227 | 228 | @Override 229 | public void onWeiboException(WeiboException e) { 230 | WritableMap event = Arguments.createMap(); 231 | event.putString("type", "WBAuthorizeResponse"); 232 | event.putString("errMsg", e.getMessage()); 233 | event.putInt("errCode", -1); 234 | getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class).emit(RCTWBEventName, event); 235 | } 236 | 237 | @Override 238 | public void onCancel() { 239 | WritableMap event = Arguments.createMap(); 240 | event.putString("type", "WBAuthorizeResponse"); 241 | event.putString("errMsg", "Cancel"); 242 | event.putInt("errCode", -1); 243 | getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class).emit(RCTWBEventName, event); 244 | } 245 | }; 246 | } 247 | 248 | private void _share(ReadableMap data, Bitmap bitmap) { 249 | 250 | this.registerShare(); 251 | WeiboMultiMessage weiboMessage = new WeiboMultiMessage();//初始化微博的分享消息 252 | TextObject textObject = new TextObject(); 253 | if (data.hasKey(RCTWBShareText)) { 254 | textObject.text = data.getString(RCTWBShareText); 255 | } 256 | weiboMessage.textObject = textObject; 257 | 258 | String type = RCTWBShareTypeNews; 259 | if (data.hasKey(RCTWBShareType)){ 260 | type = data.getString(RCTWBShareType); 261 | } 262 | 263 | if (type.equals(RCTWBShareTypeText)) { 264 | } 265 | else if (type.equals(RCTWBShareTypeImage)) { 266 | ImageObject imageObject = new ImageObject(); 267 | if (bitmap != null) { 268 | Log.e("share","hasBitmap"); 269 | imageObject.setImageObject(bitmap); 270 | } 271 | weiboMessage.imageObject = imageObject; 272 | } 273 | else { 274 | if (type.equals(RCTWBShareTypeNews)) { 275 | WebpageObject webpageObject = new WebpageObject(); 276 | if (data.hasKey(RCTWBShareWebpageUrl)) { 277 | webpageObject.actionUrl = data.getString(RCTWBShareWebpageUrl); 278 | } 279 | weiboMessage.mediaObject = webpageObject; 280 | } 281 | else if (type.equals(RCTWBShareTypeVideo)) { 282 | VideoObject videoObject = new VideoObject(); 283 | if (data.hasKey(RCTWBShareWebpageUrl)) { 284 | videoObject.dataUrl = data.getString(RCTWBShareWebpageUrl); 285 | } 286 | weiboMessage.mediaObject = videoObject; 287 | } 288 | else if (type.equals(RCTWBShareTypeAudio)) { 289 | MusicObject musicObject = new MusicObject(); 290 | if (data.hasKey(RCTWBShareWebpageUrl)) { 291 | musicObject.dataUrl = data.getString(RCTWBShareWebpageUrl); 292 | } 293 | weiboMessage.mediaObject = musicObject; 294 | } 295 | if (data.hasKey(RCTWBShareDescription)) { 296 | weiboMessage.mediaObject.description = data.getString(RCTWBShareDescription); 297 | } 298 | if (data.hasKey(RCTWBShareTitle)) { 299 | weiboMessage.mediaObject.title = data.getString(RCTWBShareTitle); 300 | } 301 | if (bitmap != null) { 302 | weiboMessage.mediaObject.setThumbImage(bitmap); 303 | } 304 | weiboMessage.mediaObject.identify = new Date().toString(); 305 | } 306 | 307 | SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest(); 308 | request.transaction = String.valueOf(System.currentTimeMillis()); 309 | request.multiMessage = weiboMessage; 310 | 311 | String accessToken = null; 312 | if (data.hasKey(RCTWBShareAccessToken)) { 313 | accessToken = data.getString(RCTWBShareAccessToken); 314 | } 315 | boolean success = mSinaShareAPI.sendRequest(getCurrentActivity(), request, null, accessToken, genWeiboAuthListener()); 316 | 317 | if (success == false) { 318 | WritableMap event = Arguments.createMap(); 319 | event.putString("type", "WBAuthorizeResponse"); 320 | event.putString("errMsg", "WeiBo API invoke returns false."); 321 | event.putInt("errCode", -1); 322 | getReactApplicationContext().getJSModule(RCTNativeAppEventEmitter.class).emit(RCTWBEventName, event); 323 | } 324 | } 325 | 326 | public static boolean handleWeiboResponse(Intent intent, IWeiboHandler.Response response) { 327 | gModule.registerShare(); 328 | boolean ret = gModule.mSinaShareAPI.handleWeiboResponse(intent, response); 329 | if (ret) { 330 | return ret; 331 | } 332 | return ret; 333 | } 334 | 335 | public static void onShareResponse(BaseResponse baseResponse) { 336 | WritableMap map = Arguments.createMap(); 337 | map.putInt("errCode", baseResponse.errCode); 338 | map.putString("errMsg", baseResponse.errMsg); 339 | map.putString("type", "WBSendMessageToWeiboResponse"); 340 | gModule.getReactApplicationContext() 341 | .getJSModule(RCTNativeAppEventEmitter.class) 342 | .emit(RCTWBEventName, map); 343 | } 344 | 345 | static public class SinaEntryActivity extends Activity implements IWeiboHandler.Response { 346 | @Override 347 | protected void onCreate(Bundle savedInstanceState) { 348 | super.onCreate(savedInstanceState); 349 | WeiboModule.handleWeiboResponse(getIntent(), this); 350 | } 351 | 352 | @Override 353 | public void onResponse(BaseResponse baseResponse) { 354 | WeiboModule.onShareResponse(baseResponse); 355 | this.finish(); 356 | } 357 | } 358 | 359 | private AuthInfo _genAuthInfo(ReadableMap config) { 360 | String redirectURI = ""; 361 | if (config.hasKey("redirectURI")) { 362 | redirectURI = config.getString("redirectURI"); 363 | } 364 | String scope = ""; 365 | if (config.hasKey("scope")) { 366 | scope = config.getString("scope"); 367 | } 368 | final AuthInfo sinaAuthInfo = new AuthInfo(getReactApplicationContext(), this.appId, redirectURI, scope); 369 | return sinaAuthInfo; 370 | } 371 | 372 | private void _downloadImage(String imageUrl, ResizeOptions resizeOptions,DataSubscriber> dataSubscriber) { 373 | Uri uri = null; 374 | try { 375 | uri = Uri.parse(imageUrl); 376 | // Verify scheme is set, so that relative uri (used by static resources) are not handled. 377 | if (uri.getScheme() == null) { 378 | uri = null; 379 | } 380 | } catch (Exception e) { 381 | // ignore malformed uri, then attempt to extract resource ID. 382 | } 383 | if (uri == null) { 384 | uri = _getResourceDrawableUri(getReactApplicationContext(), imageUrl); 385 | } else { 386 | } 387 | 388 | ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(uri); 389 | if (resizeOptions != null) { 390 | builder.setResizeOptions(resizeOptions); 391 | } 392 | ImageRequest imageRequest = builder.build(); 393 | 394 | ImagePipeline imagePipeline = Fresco.getImagePipeline(); 395 | DataSource> dataSource = imagePipeline.fetchDecodedImage(imageRequest, null); 396 | dataSource.subscribe(dataSubscriber, UiThreadImmediateExecutorService.getInstance()); 397 | } 398 | 399 | private static @Nullable 400 | Uri _getResourceDrawableUri(Context context, @Nullable String name) { 401 | if (name == null || name.isEmpty()) { 402 | return null; 403 | } 404 | name = name.toLowerCase().replace("-", "_"); 405 | int resId = context.getResources().getIdentifier( 406 | name, 407 | "drawable", 408 | context.getPackageName()); 409 | return new Uri.Builder() 410 | .scheme(UriUtil.LOCAL_RESOURCE_SCHEME) 411 | .path(String.valueOf(resId)) 412 | .build(); 413 | } 414 | 415 | private Drawable _createDrawable(CloseableReference image) { 416 | Preconditions.checkState(CloseableReference.isValid(image)); 417 | CloseableImage closeableImage = image.get(); 418 | if (closeableImage instanceof CloseableStaticBitmap) { 419 | CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) closeableImage; 420 | BitmapDrawable bitmapDrawable = new BitmapDrawable( 421 | getReactApplicationContext().getResources(), 422 | closeableStaticBitmap.getUnderlyingBitmap()); 423 | if (closeableStaticBitmap.getRotationAngle() == 0 || 424 | closeableStaticBitmap.getRotationAngle() == EncodedImage.UNKNOWN_ROTATION_ANGLE) { 425 | return bitmapDrawable; 426 | } else { 427 | return new OrientedDrawable(bitmapDrawable, closeableStaticBitmap.getRotationAngle()); 428 | } 429 | } else { 430 | throw new UnsupportedOperationException("Unrecognized image class: " + closeableImage); 431 | } 432 | } 433 | 434 | private Bitmap _drawable2Bitmap(Drawable drawable) { 435 | if (drawable instanceof BitmapDrawable) { 436 | return ((BitmapDrawable) drawable).getBitmap(); 437 | } else if (drawable instanceof NinePatchDrawable) { 438 | Bitmap bitmap = Bitmap 439 | .createBitmap( 440 | drawable.getIntrinsicWidth(), 441 | drawable.getIntrinsicHeight(), 442 | drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 443 | : Bitmap.Config.RGB_565); 444 | Canvas canvas = new Canvas(bitmap); 445 | drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), 446 | drawable.getIntrinsicHeight()); 447 | drawable.draw(canvas); 448 | return bitmap; 449 | } else { 450 | return null; 451 | } 452 | } 453 | } 454 | -------------------------------------------------------------------------------- /android/src/main/java/cn/reactnative/modules/weibo/WeiboPackage.java: -------------------------------------------------------------------------------- 1 | package cn.reactnative.modules.weibo; 2 | 3 | import com.facebook.react.ReactPackage; 4 | import com.facebook.react.bridge.JavaScriptModule; 5 | import com.facebook.react.bridge.NativeModule; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.uimanager.ViewManager; 8 | 9 | import java.util.Arrays; 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | /** 14 | * Created by lvbingru on 12/22/15. 15 | */ 16 | public class WeiboPackage implements ReactPackage { 17 | @Override 18 | public List createNativeModules(ReactApplicationContext reactContext) { 19 | return Arrays.asList(new NativeModule[]{ 20 | // Modules from third-party 21 | new WeiboModule(reactContext), 22 | }); 23 | } 24 | 25 | public List> createJSModules() { 26 | return Collections.emptyList(); 27 | } 28 | 29 | @Override 30 | public List createViewManagers(ReactApplicationContext reactContext) { 31 | return Collections.emptyList(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /android/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | react-native-weibo 3 | 4 | -------------------------------------------------------------------------------- /android/src/test/java/cn/reactnative/modules/weibo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package cn.reactnative.modules.weibo; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by lvbingru on 1/5/16. 3 | */ 4 | 5 | import {NativeModules, NativeAppEventEmitter} from 'react-native'; 6 | import promisify from 'es6-promisify'; 7 | 8 | const {WeiboAPI} = NativeModules; 9 | 10 | // Used only with promisify. Transform callback to promise result. 11 | function translateError(err, result) { 12 | if (!err) { 13 | return this.resolve(result); 14 | } 15 | if (typeof err === 'object') { 16 | if (err instanceof Error) { 17 | return this.reject(ret); 18 | } 19 | return this.reject(Object.assign(new Error(err.message), { errCode: err.errCode })); 20 | } else if (typeof err === 'string') { 21 | return this.reject(new Error(err)); 22 | } 23 | this.reject(Object.assign(new Error(), { origin: err })); 24 | } 25 | 26 | function wrapApi(nativeFunc) { 27 | if (!nativeFunc) { 28 | return undefined; 29 | } 30 | const promisified = promisify(nativeFunc, translateError); 31 | return (...args) => { 32 | return promisified(...args); 33 | }; 34 | } 35 | 36 | // Save callback and wait for future event. 37 | let savedCallback = undefined; 38 | function waitForResponse(type) { 39 | return new Promise((resolve, reject) => { 40 | if (savedCallback) { 41 | savedCallback('User canceled.'); 42 | } 43 | savedCallback = result => { 44 | if (result.type !== type) { 45 | return; 46 | } 47 | savedCallback = undefined; 48 | if (result.errCode !== 0) { 49 | const err = new Error(result.errMsg); 50 | err.errCode = result.errCode; 51 | reject(err); 52 | } else { 53 | resolve(result); 54 | } 55 | }; 56 | }); 57 | } 58 | 59 | NativeAppEventEmitter.addListener('Weibo_Resp', resp => { 60 | const callback = savedCallback; 61 | savedCallback = undefined; 62 | callback && callback(resp); 63 | }); 64 | 65 | 66 | const defaultScope = "all" 67 | const defaultRedirectURI = "https://api.weibo.com/oauth2/default.html" 68 | 69 | function checkData(data) { 70 | if(!data.redirectURI) { 71 | data.redirectURI = defaultRedirectURI 72 | } 73 | if(!data.scope) { 74 | data.scope = defaultScope 75 | } 76 | } 77 | 78 | const nativeSendAuthRequest = wrapApi(WeiboAPI.login); 79 | const nativeSendMessageRequest = wrapApi(WeiboAPI.shareToWeibo); 80 | 81 | export function login(config={}) { 82 | checkData(config) 83 | return Promise.all([waitForResponse('WBAuthorizeResponse'), nativeSendAuthRequest(config)]).then(v=>v[0]); 84 | } 85 | 86 | export function share(data) { 87 | checkData(data) 88 | return Promise.all([waitForResponse('WBSendMessageToWeiboResponse'), nativeSendMessageRequest(data)]).then(v=>v[0]); 89 | } 90 | 91 | -------------------------------------------------------------------------------- /ios/RCTWeiboAPI.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 915450F91C3D1520000CBFD2 /* RCTWeiboAPI.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 915450F81C3D1520000CBFD2 /* RCTWeiboAPI.h */; }; 11 | 915450FB1C3D1520000CBFD2 /* RCTWeiboAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = 915450FA1C3D1520000CBFD2 /* RCTWeiboAPI.m */; }; 12 | 9154511B1C3D161E000CBFD2 /* libWeiboSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9154510F1C3D161E000CBFD2 /* libWeiboSDK.a */; }; 13 | /* End PBXBuildFile section */ 14 | 15 | /* Begin PBXCopyFilesBuildPhase section */ 16 | 915450F31C3D1520000CBFD2 /* CopyFiles */ = { 17 | isa = PBXCopyFilesBuildPhase; 18 | buildActionMask = 2147483647; 19 | dstPath = "include/$(PRODUCT_NAME)"; 20 | dstSubfolderSpec = 16; 21 | files = ( 22 | 915450F91C3D1520000CBFD2 /* RCTWeiboAPI.h in CopyFiles */, 23 | ); 24 | runOnlyForDeploymentPostprocessing = 0; 25 | }; 26 | /* End PBXCopyFilesBuildPhase section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | 915450F51C3D1520000CBFD2 /* libRCTWeiboAPI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTWeiboAPI.a; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | 915450F81C3D1520000CBFD2 /* RCTWeiboAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTWeiboAPI.h; sourceTree = ""; }; 31 | 915450FA1C3D1520000CBFD2 /* RCTWeiboAPI.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTWeiboAPI.m; sourceTree = ""; }; 32 | 9154510F1C3D161E000CBFD2 /* libWeiboSDK.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libWeiboSDK.a; sourceTree = ""; }; 33 | 915451101C3D161E000CBFD2 /* WBHttpRequest+WeiboGame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WBHttpRequest+WeiboGame.h"; sourceTree = ""; }; 34 | 915451111C3D161E000CBFD2 /* WBHttpRequest+WeiboShare.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WBHttpRequest+WeiboShare.h"; sourceTree = ""; }; 35 | 915451121C3D161E000CBFD2 /* WBHttpRequest+WeiboToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WBHttpRequest+WeiboToken.h"; sourceTree = ""; }; 36 | 915451131C3D161E000CBFD2 /* WBHttpRequest+WeiboUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WBHttpRequest+WeiboUser.h"; sourceTree = ""; }; 37 | 915451141C3D161E000CBFD2 /* WBHttpRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBHttpRequest.h; sourceTree = ""; }; 38 | 915451151C3D161E000CBFD2 /* WBSDKBasicButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBSDKBasicButton.h; sourceTree = ""; }; 39 | 915451161C3D161E000CBFD2 /* WBSDKCommentButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBSDKCommentButton.h; sourceTree = ""; }; 40 | 915451171C3D161E000CBFD2 /* WBSDKRelationshipButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBSDKRelationshipButton.h; sourceTree = ""; }; 41 | 915451181C3D161E000CBFD2 /* WeiboSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = WeiboSDK.bundle; sourceTree = ""; }; 42 | 915451191C3D161E000CBFD2 /* WeiboSDK.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeiboSDK.h; sourceTree = ""; }; 43 | 9154511A1C3D161E000CBFD2 /* WeiboUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeiboUser.h; sourceTree = ""; }; 44 | /* End PBXFileReference section */ 45 | 46 | /* Begin PBXFrameworksBuildPhase section */ 47 | 915450F21C3D1520000CBFD2 /* Frameworks */ = { 48 | isa = PBXFrameworksBuildPhase; 49 | buildActionMask = 2147483647; 50 | files = ( 51 | 9154511B1C3D161E000CBFD2 /* libWeiboSDK.a in Frameworks */, 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 915450EC1C3D1520000CBFD2 = { 59 | isa = PBXGroup; 60 | children = ( 61 | 9154510E1C3D161E000CBFD2 /* libWeiboSDK */, 62 | 915450F71C3D1520000CBFD2 /* RCTWeiboAPI */, 63 | 915450F61C3D1520000CBFD2 /* Products */, 64 | ); 65 | sourceTree = ""; 66 | }; 67 | 915450F61C3D1520000CBFD2 /* Products */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | 915450F51C3D1520000CBFD2 /* libRCTWeiboAPI.a */, 71 | ); 72 | name = Products; 73 | sourceTree = ""; 74 | }; 75 | 915450F71C3D1520000CBFD2 /* RCTWeiboAPI */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 915450F81C3D1520000CBFD2 /* RCTWeiboAPI.h */, 79 | 915450FA1C3D1520000CBFD2 /* RCTWeiboAPI.m */, 80 | ); 81 | path = RCTWeiboAPI; 82 | sourceTree = ""; 83 | }; 84 | 9154510E1C3D161E000CBFD2 /* libWeiboSDK */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 9154510F1C3D161E000CBFD2 /* libWeiboSDK.a */, 88 | 915451101C3D161E000CBFD2 /* WBHttpRequest+WeiboGame.h */, 89 | 915451111C3D161E000CBFD2 /* WBHttpRequest+WeiboShare.h */, 90 | 915451121C3D161E000CBFD2 /* WBHttpRequest+WeiboToken.h */, 91 | 915451131C3D161E000CBFD2 /* WBHttpRequest+WeiboUser.h */, 92 | 915451141C3D161E000CBFD2 /* WBHttpRequest.h */, 93 | 915451151C3D161E000CBFD2 /* WBSDKBasicButton.h */, 94 | 915451161C3D161E000CBFD2 /* WBSDKCommentButton.h */, 95 | 915451171C3D161E000CBFD2 /* WBSDKRelationshipButton.h */, 96 | 915451181C3D161E000CBFD2 /* WeiboSDK.bundle */, 97 | 915451191C3D161E000CBFD2 /* WeiboSDK.h */, 98 | 9154511A1C3D161E000CBFD2 /* WeiboUser.h */, 99 | ); 100 | path = libWeiboSDK; 101 | sourceTree = ""; 102 | }; 103 | /* End PBXGroup section */ 104 | 105 | /* Begin PBXNativeTarget section */ 106 | 915450F41C3D1520000CBFD2 /* RCTWeiboAPI */ = { 107 | isa = PBXNativeTarget; 108 | buildConfigurationList = 915450FE1C3D1520000CBFD2 /* Build configuration list for PBXNativeTarget "RCTWeiboAPI" */; 109 | buildPhases = ( 110 | 915450F11C3D1520000CBFD2 /* Sources */, 111 | 915450F21C3D1520000CBFD2 /* Frameworks */, 112 | 915450F31C3D1520000CBFD2 /* CopyFiles */, 113 | ); 114 | buildRules = ( 115 | ); 116 | dependencies = ( 117 | ); 118 | name = RCTWeiboAPI; 119 | productName = RCTWeiboAPI; 120 | productReference = 915450F51C3D1520000CBFD2 /* libRCTWeiboAPI.a */; 121 | productType = "com.apple.product-type.library.static"; 122 | }; 123 | /* End PBXNativeTarget section */ 124 | 125 | /* Begin PBXProject section */ 126 | 915450ED1C3D1520000CBFD2 /* Project object */ = { 127 | isa = PBXProject; 128 | attributes = { 129 | LastUpgradeCheck = 0720; 130 | ORGANIZATIONNAME = erica; 131 | TargetAttributes = { 132 | 915450F41C3D1520000CBFD2 = { 133 | CreatedOnToolsVersion = 7.2; 134 | }; 135 | }; 136 | }; 137 | buildConfigurationList = 915450F01C3D1520000CBFD2 /* Build configuration list for PBXProject "RCTWeiboAPI" */; 138 | compatibilityVersion = "Xcode 3.2"; 139 | developmentRegion = English; 140 | hasScannedForEncodings = 0; 141 | knownRegions = ( 142 | en, 143 | ); 144 | mainGroup = 915450EC1C3D1520000CBFD2; 145 | productRefGroup = 915450F61C3D1520000CBFD2 /* Products */; 146 | projectDirPath = ""; 147 | projectRoot = ""; 148 | targets = ( 149 | 915450F41C3D1520000CBFD2 /* RCTWeiboAPI */, 150 | ); 151 | }; 152 | /* End PBXProject section */ 153 | 154 | /* Begin PBXSourcesBuildPhase section */ 155 | 915450F11C3D1520000CBFD2 /* Sources */ = { 156 | isa = PBXSourcesBuildPhase; 157 | buildActionMask = 2147483647; 158 | files = ( 159 | 915450FB1C3D1520000CBFD2 /* RCTWeiboAPI.m in Sources */, 160 | ); 161 | runOnlyForDeploymentPostprocessing = 0; 162 | }; 163 | /* End PBXSourcesBuildPhase section */ 164 | 165 | /* Begin XCBuildConfiguration section */ 166 | 915450FC1C3D1520000CBFD2 /* Debug */ = { 167 | isa = XCBuildConfiguration; 168 | buildSettings = { 169 | ALWAYS_SEARCH_USER_PATHS = NO; 170 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 171 | CLANG_CXX_LIBRARY = "libc++"; 172 | CLANG_ENABLE_MODULES = YES; 173 | CLANG_ENABLE_OBJC_ARC = YES; 174 | CLANG_WARN_BOOL_CONVERSION = YES; 175 | CLANG_WARN_CONSTANT_CONVERSION = YES; 176 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 177 | CLANG_WARN_EMPTY_BODY = YES; 178 | CLANG_WARN_ENUM_CONVERSION = YES; 179 | CLANG_WARN_INT_CONVERSION = YES; 180 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 181 | CLANG_WARN_UNREACHABLE_CODE = YES; 182 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 183 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 184 | COPY_PHASE_STRIP = NO; 185 | DEBUG_INFORMATION_FORMAT = dwarf; 186 | ENABLE_STRICT_OBJC_MSGSEND = YES; 187 | ENABLE_TESTABILITY = YES; 188 | GCC_C_LANGUAGE_STANDARD = gnu99; 189 | GCC_DYNAMIC_NO_PIC = NO; 190 | GCC_NO_COMMON_BLOCKS = YES; 191 | GCC_OPTIMIZATION_LEVEL = 0; 192 | GCC_PREPROCESSOR_DEFINITIONS = ( 193 | "DEBUG=1", 194 | "$(inherited)", 195 | ); 196 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 197 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 198 | GCC_WARN_UNDECLARED_SELECTOR = YES; 199 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 200 | GCC_WARN_UNUSED_FUNCTION = YES; 201 | GCC_WARN_UNUSED_VARIABLE = YES; 202 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 203 | MTL_ENABLE_DEBUG_INFO = YES; 204 | ONLY_ACTIVE_ARCH = YES; 205 | SDKROOT = iphoneos; 206 | }; 207 | name = Debug; 208 | }; 209 | 915450FD1C3D1520000CBFD2 /* Release */ = { 210 | isa = XCBuildConfiguration; 211 | buildSettings = { 212 | ALWAYS_SEARCH_USER_PATHS = NO; 213 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 214 | CLANG_CXX_LIBRARY = "libc++"; 215 | CLANG_ENABLE_MODULES = YES; 216 | CLANG_ENABLE_OBJC_ARC = YES; 217 | CLANG_WARN_BOOL_CONVERSION = YES; 218 | CLANG_WARN_CONSTANT_CONVERSION = YES; 219 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 220 | CLANG_WARN_EMPTY_BODY = YES; 221 | CLANG_WARN_ENUM_CONVERSION = YES; 222 | CLANG_WARN_INT_CONVERSION = YES; 223 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 224 | CLANG_WARN_UNREACHABLE_CODE = YES; 225 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 226 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 227 | COPY_PHASE_STRIP = NO; 228 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 229 | ENABLE_NS_ASSERTIONS = NO; 230 | ENABLE_STRICT_OBJC_MSGSEND = YES; 231 | GCC_C_LANGUAGE_STANDARD = gnu99; 232 | GCC_NO_COMMON_BLOCKS = YES; 233 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 234 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 235 | GCC_WARN_UNDECLARED_SELECTOR = YES; 236 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 237 | GCC_WARN_UNUSED_FUNCTION = YES; 238 | GCC_WARN_UNUSED_VARIABLE = YES; 239 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 240 | MTL_ENABLE_DEBUG_INFO = NO; 241 | SDKROOT = iphoneos; 242 | VALIDATE_PRODUCT = YES; 243 | }; 244 | name = Release; 245 | }; 246 | 915450FF1C3D1520000CBFD2 /* Debug */ = { 247 | isa = XCBuildConfiguration; 248 | buildSettings = { 249 | HEADER_SEARCH_PATHS = ( 250 | "$(inherited)", 251 | "$(SRCROOT)/../../react-native/React/**", 252 | "$(SRCROOT)/../../react-native/Libraries/**", 253 | "$(BUILT_PRODUCTS_DIR)/include/**", 254 | ); 255 | LIBRARY_SEARCH_PATHS = ( 256 | "$(inherited)", 257 | "$(PROJECT_DIR)/libWeiboSDK", 258 | ); 259 | OTHER_LDFLAGS = "-ObjC"; 260 | PRODUCT_NAME = "$(TARGET_NAME)"; 261 | SKIP_INSTALL = YES; 262 | }; 263 | name = Debug; 264 | }; 265 | 915451001C3D1520000CBFD2 /* Release */ = { 266 | isa = XCBuildConfiguration; 267 | buildSettings = { 268 | HEADER_SEARCH_PATHS = ( 269 | "$(inherited)", 270 | "$(SRCROOT)/../../react-native/React/**", 271 | "$(SRCROOT)/../../react-native/Libraries/**", 272 | "$(BUILT_PRODUCTS_DIR)/include/**", 273 | ); 274 | LIBRARY_SEARCH_PATHS = ( 275 | "$(inherited)", 276 | "$(PROJECT_DIR)/libWeiboSDK", 277 | ); 278 | OTHER_LDFLAGS = "-ObjC"; 279 | PRODUCT_NAME = "$(TARGET_NAME)"; 280 | SKIP_INSTALL = YES; 281 | }; 282 | name = Release; 283 | }; 284 | /* End XCBuildConfiguration section */ 285 | 286 | /* Begin XCConfigurationList section */ 287 | 915450F01C3D1520000CBFD2 /* Build configuration list for PBXProject "RCTWeiboAPI" */ = { 288 | isa = XCConfigurationList; 289 | buildConfigurations = ( 290 | 915450FC1C3D1520000CBFD2 /* Debug */, 291 | 915450FD1C3D1520000CBFD2 /* Release */, 292 | ); 293 | defaultConfigurationIsVisible = 0; 294 | defaultConfigurationName = Release; 295 | }; 296 | 915450FE1C3D1520000CBFD2 /* Build configuration list for PBXNativeTarget "RCTWeiboAPI" */ = { 297 | isa = XCConfigurationList; 298 | buildConfigurations = ( 299 | 915450FF1C3D1520000CBFD2 /* Debug */, 300 | 915451001C3D1520000CBFD2 /* Release */, 301 | ); 302 | defaultConfigurationIsVisible = 0; 303 | defaultConfigurationName = Release; 304 | }; 305 | /* End XCConfigurationList section */ 306 | }; 307 | rootObject = 915450ED1C3D1520000CBFD2 /* Project object */; 308 | } 309 | -------------------------------------------------------------------------------- /ios/RCTWeiboAPI.xcodeproj/xcuserdata/lvbingru.xcuserdatad/xcschemes/RCTWeiboAPI.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /ios/RCTWeiboAPI/RCTWeiboAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // RCTWeiboAPI.h 3 | // RCTWeiboAPI 4 | // 5 | // Created by LvBingru on 1/6/16. 6 | // Copyright © 2016 erica. All rights reserved. 7 | // 8 | 9 | #import "RCTBridgeModule.h" 10 | 11 | @interface RCTWeiboAPI : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/RCTWeiboAPI/RCTWeiboAPI.m: -------------------------------------------------------------------------------- 1 | // 2 | // RCTWeiboAPI.m 3 | // RCTWeiboAPI 4 | // 5 | // Created by LvBingru on 1/6/16. 6 | // Copyright © 2016 erica. All rights reserved. 7 | // 8 | 9 | #import "RCTWeiboAPI.h" 10 | #import "WeiboSDK.h" 11 | 12 | #if __has_include() 13 | #import 14 | #import 15 | #import 16 | #else 17 | #import "RCTBridge.h" 18 | #import "RCTEventDispatcher.h" 19 | #import "RCTImageLoader.h" 20 | #endif 21 | 22 | #define INVOKE_FAILED (@"WeiBo API invoke returns false.") 23 | #define RCTWBEventName (@"Weibo_Resp") 24 | 25 | 26 | #define RCTWBShareTypeNews @"news" 27 | #define RCTWBShareTypeImage @"image" 28 | #define RCTWBShareTypeText @"text" 29 | #define RCTWBShareTypeVideo @"video" 30 | #define RCTWBShareTypeAudio @"audio" 31 | 32 | #define RCTWBShareType @"type" 33 | #define RCTWBShareText @"text" 34 | #define RCTWBShareTitle @"title" 35 | #define RCTWBShareDescription @"description" 36 | #define RCTWBShareWebpageUrl @"webpageUrl" 37 | #define RCTWBShareImageUrl @"imageUrl" 38 | #define RCTWBShareAccessToken @"accessToken" 39 | 40 | BOOL gRegister = NO; 41 | 42 | @interface RCTWeiboAPI() 43 | 44 | @end 45 | 46 | @implementation RCTWeiboAPI 47 | 48 | @synthesize bridge = _bridge; 49 | 50 | RCT_EXPORT_MODULE(); 51 | 52 | - (dispatch_queue_t)methodQueue 53 | { 54 | return dispatch_get_main_queue(); 55 | } 56 | 57 | - (instancetype)init 58 | { 59 | self = [super init]; 60 | if (self) { 61 | 62 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:@"RCTOpenURLNotification" object:nil]; 63 | } 64 | return self; 65 | } 66 | 67 | - (void)dealloc 68 | { 69 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 70 | } 71 | 72 | RCT_EXPORT_METHOD(login:(NSDictionary *)config 73 | :(RCTResponseSenderBlock)callback) 74 | { 75 | [self _autoRegisterAPI]; 76 | 77 | WBAuthorizeRequest *request = [self _genAuthRequest:config]; 78 | BOOL success = [WeiboSDK sendRequest:request]; 79 | callback(@[success?[NSNull null]:INVOKE_FAILED]); 80 | } 81 | 82 | RCT_EXPORT_METHOD(logout) 83 | { 84 | [WeiboSDK logOutWithToken:nil delegate:nil withTag:nil]; 85 | } 86 | 87 | RCT_EXPORT_METHOD(shareToWeibo:(NSDictionary *)aData 88 | :(RCTResponseSenderBlock)callback) 89 | { 90 | [self _autoRegisterAPI]; 91 | 92 | NSString *imageUrl = aData[RCTWBShareImageUrl]; 93 | if (imageUrl.length && _bridge.imageLoader) { 94 | CGSize size = CGSizeZero; 95 | if (![aData[RCTWBShareType] isEqualToString:RCTWBShareTypeImage]) { 96 | size = CGSizeMake(80,80); 97 | } 98 | [_bridge.imageLoader loadImageWithURLRequest:[RCTConvert NSURLRequest:imageUrl] size:size scale:1 clipped:FALSE resizeMode:UIViewContentModeScaleToFill progressBlock:nil partialLoadBlock: nil completionBlock:^(NSError *error, UIImage *image) { 99 | [self _shareWithData:aData image:image]; 100 | }]; 101 | } 102 | else { 103 | [self _shareWithData:aData image:nil]; 104 | } 105 | callback(@[[NSNull null]]); 106 | } 107 | 108 | 109 | - (void)handleOpenURL:(NSNotification *)note 110 | { 111 | NSDictionary *userInfo = note.userInfo; 112 | NSString *url = userInfo[@"url"]; 113 | [WeiboSDK handleOpenURL:[NSURL URLWithString:url] delegate:self]; 114 | } 115 | 116 | 117 | #pragma mark - sina delegate 118 | - (void)didReceiveWeiboRequest:(WBBaseRequest *)request 119 | { 120 | if ([request isKindOfClass:WBProvideMessageForWeiboRequest.class]) 121 | { 122 | 123 | } 124 | } 125 | 126 | - (void)didReceiveWeiboResponse:(WBBaseResponse *)response 127 | { 128 | NSMutableDictionary *body = [NSMutableDictionary new]; 129 | body[@"errCode"] = @(response.statusCode); 130 | // 分享 131 | if ([response isKindOfClass:WBSendMessageToWeiboResponse.class]) 132 | { 133 | body[@"type"] = @"WBSendMessageToWeiboResponse"; 134 | if (response.statusCode == WeiboSDKResponseStatusCodeSuccess) 135 | { 136 | WBSendMessageToWeiboResponse *sendResponse = (WBSendMessageToWeiboResponse *)response; 137 | WBAuthorizeResponse *authorizeResponse = sendResponse.authResponse; 138 | if (sendResponse.authResponse != nil) { 139 | body[@"userID"] = authorizeResponse.userID; 140 | body[@"accessToken"] = authorizeResponse.accessToken; 141 | body[@"expirationDate"] = @([authorizeResponse.expirationDate timeIntervalSince1970]); 142 | body[@"refreshToken"] = authorizeResponse.refreshToken; 143 | } 144 | } 145 | else 146 | { 147 | body[@"errMsg"] = [self _getErrMsg:response.statusCode]; 148 | } 149 | } 150 | // 认证 151 | else if ([response isKindOfClass:WBAuthorizeResponse.class]) 152 | { 153 | body[@"type"] = @"WBAuthorizeResponse"; 154 | if (response.statusCode == WeiboSDKResponseStatusCodeSuccess) 155 | { 156 | WBAuthorizeResponse *authorizeResponse = (WBAuthorizeResponse *)response; 157 | body[@"userID"] = authorizeResponse.userID; 158 | body[@"accessToken"] = authorizeResponse.accessToken; 159 | body[@"expirationDate"] = @([authorizeResponse.expirationDate timeIntervalSince1970]*1000); 160 | body[@"refreshToken"] = authorizeResponse.refreshToken; 161 | } 162 | else 163 | { 164 | body[@"errMsg"] = [self _getErrMsg:response.statusCode]; 165 | } 166 | } 167 | [self.bridge.eventDispatcher sendAppEventWithName:RCTWBEventName body:body]; 168 | } 169 | 170 | #pragma mark - private 171 | 172 | // 如果js没有调用registerApp,自动从plist中读取appId 173 | - (void)_autoRegisterAPI 174 | { 175 | if (gRegister) { 176 | return; 177 | } 178 | 179 | NSArray *list = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleURLTypes"]; 180 | for (NSDictionary *item in list) { 181 | NSString *name = item[@"CFBundleURLName"]; 182 | if ([name isEqualToString:@"sina"]) { 183 | NSArray *schemes = item[@"CFBundleURLSchemes"]; 184 | if (schemes.count > 0) 185 | { 186 | NSString *appId = [schemes[0] substringFromIndex:@"wb".length]; 187 | if ([WeiboSDK registerApp:appId]) { 188 | gRegister = YES; 189 | } 190 | #ifdef DEBUG 191 | [WeiboSDK enableDebugMode:YES]; 192 | #endif 193 | break; 194 | } 195 | } 196 | } 197 | } 198 | 199 | - (NSString *)_getErrMsg:(NSInteger)errCode 200 | { 201 | NSString *errMsg = @"微博认证失败"; 202 | switch (errCode) { 203 | case WeiboSDKResponseStatusCodeUserCancel: 204 | errMsg = @"用户取消发送"; 205 | break; 206 | case WeiboSDKResponseStatusCodeSentFail: 207 | errMsg = @"发送失败"; 208 | break; 209 | case WeiboSDKResponseStatusCodeAuthDeny: 210 | errMsg = @"授权失败"; 211 | break; 212 | case WeiboSDKResponseStatusCodeUserCancelInstall: 213 | errMsg = @"用户取消安装微博客户端"; 214 | break; 215 | case WeiboSDKResponseStatusCodePayFail: 216 | errMsg = @"支付失败"; 217 | break; 218 | case WeiboSDKResponseStatusCodeShareInSDKFailed: 219 | errMsg = @"分享失败"; 220 | break; 221 | case WeiboSDKResponseStatusCodeUnsupport: 222 | errMsg = @"不支持的请求"; 223 | break; 224 | default: 225 | errMsg = @"位置"; 226 | break; 227 | } 228 | return errMsg; 229 | } 230 | 231 | - (void)_shareWithData:(NSDictionary *)aData image:(UIImage *)aImage 232 | { 233 | WBMessageObject *message = [WBMessageObject message]; 234 | NSString *text = aData[RCTWBShareText]; 235 | message.text = text; 236 | 237 | NSString *type = aData[RCTWBShareType]; 238 | if ([type isEqualToString:RCTWBShareTypeText]) { 239 | } 240 | else if ([type isEqualToString:RCTWBShareTypeImage]) { 241 | // 大小不能超过10M 242 | WBImageObject *imageObject = [WBImageObject new]; 243 | if (aImage) { 244 | imageObject.imageData = UIImageJPEGRepresentation(aImage, 0.7); 245 | } 246 | message.imageObject = imageObject; 247 | } 248 | else { 249 | if ([type isEqualToString:RCTWBShareTypeVideo]) { 250 | WBVideoObject *videoObject = [WBVideoObject new]; 251 | videoObject.videoUrl = aData[RCTWBShareWebpageUrl]; 252 | message.mediaObject = videoObject; 253 | } 254 | else if ([type isEqualToString:RCTWBShareTypeAudio]) { 255 | WBMusicObject *musicObject = [WBMusicObject new]; 256 | musicObject.musicUrl = aData[RCTWBShareWebpageUrl]; 257 | message.mediaObject = musicObject; 258 | } 259 | else { 260 | WBWebpageObject *webpageObject = [WBWebpageObject new]; 261 | webpageObject.webpageUrl = aData[RCTWBShareWebpageUrl]; 262 | message.mediaObject = webpageObject; 263 | } 264 | message.mediaObject.objectID = [NSDate date].description; 265 | message.mediaObject.description = aData[RCTWBShareDescription]; 266 | message.mediaObject.title = aData[RCTWBShareTitle]; 267 | if (aImage) { 268 | // @warning 大小小于32k 269 | message.mediaObject.thumbnailData = UIImageJPEGRepresentation(aImage, 0.7); 270 | } 271 | } 272 | 273 | WBAuthorizeRequest *authRequest = [self _genAuthRequest:aData]; 274 | NSString *accessToken = aData[RCTWBShareAccessToken]; 275 | WBSendMessageToWeiboRequest *request = [WBSendMessageToWeiboRequest requestWithMessage:message authInfo:authRequest access_token:accessToken]; 276 | 277 | BOOL success = [WeiboSDK sendRequest:request]; 278 | if (!success) { 279 | NSMutableDictionary *body = [NSMutableDictionary new]; 280 | body[@"errMsg"] = INVOKE_FAILED; 281 | body[@"errCode"] = @(-1); 282 | body[@"type"] = @"WBSendMessageToWeiboResponse"; 283 | [_bridge.eventDispatcher sendAppEventWithName:RCTWBEventName body:body]; 284 | } 285 | } 286 | 287 | - (WBAuthorizeRequest *)_genAuthRequest:(NSDictionary *)config 288 | { 289 | NSString *redirectURI = config[@"redirectURI"]; 290 | NSString *scope = config[@"scope"]; 291 | 292 | WBAuthorizeRequest *authRequest = [WBAuthorizeRequest request]; 293 | authRequest.redirectURI = redirectURI; 294 | authRequest.scope = scope; 295 | 296 | return authRequest; 297 | } 298 | 299 | @end 300 | -------------------------------------------------------------------------------- /ios/libWeiboSDK/WBHttpRequest+WeiboGame.h: -------------------------------------------------------------------------------- 1 | // 2 | // WBHttpRequest+WeiboGame.h 3 | // WeiboSDK 4 | // 5 | // Created by insomnia on 15/3/11. 6 | // Copyright (c) 2015年 SINA iOS Team. All rights reserved. 7 | // 8 | 9 | #import "WBHttpRequest.h" 10 | 11 | @interface WBHttpRequest (WeiboGame) 12 | 13 | /*! 14 | @method 15 | 16 | @abstract 17 | 新增游戏对象。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 18 | 19 | @param userID 当前授权用户的uid 20 | 21 | @param accessToken 当前授权用户的accessToken 22 | 23 | @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 24 | 25 | @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 26 | 27 | @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 28 | */ 29 | + (WBHttpRequest *)addGameObject:(NSString*)userID 30 | withAccessToken:(NSString*)accessToken 31 | andOtherProperties:(NSDictionary*)otherProperties 32 | queue:(NSOperationQueue*)queue 33 | withCompletionHandler:(WBRequestHandler)handler; 34 | 35 | /*! 36 | @method 37 | 38 | @abstract 39 | 游戏成就对象入库/更新。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 40 | 41 | @param userID 当前授权用户的uid 42 | 43 | @param accessToken 当前授权用户的accessToken 44 | 45 | @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 46 | 47 | @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 48 | 49 | @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 50 | */ 51 | + (WBHttpRequest *)addGameAchievementObject:(NSString*)userID 52 | withAccessToken:(NSString*)accessToken 53 | andOtherProperties:(NSDictionary*)otherProperties 54 | queue:(NSOperationQueue*)queue 55 | withCompletionHandler:(WBRequestHandler)handler; 56 | 57 | /*! 58 | @method 59 | 60 | @abstract 61 | 用户获得游戏成就关系入库/更新。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 62 | 63 | @param userID 当前授权用户的uid 64 | 65 | @param accessToken 当前授权用户的accessToken 66 | 67 | @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 68 | 69 | @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 70 | 71 | @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 72 | */ 73 | + (WBHttpRequest *)addGameAchievementGain:(NSString*)userID 74 | withAccessToken:(NSString*)accessToken 75 | andOtherProperties:(NSDictionary*)otherProperties 76 | queue:(NSOperationQueue*)queue 77 | withCompletionHandler:(WBRequestHandler)handler; 78 | 79 | /*! 80 | @method 81 | 82 | @abstract 83 | 用户游戏得分关系入库/更新。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 84 | 85 | @param userID 当前授权用户的uid 86 | 87 | @param accessToken 当前授权用户的accessToken 88 | 89 | @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 90 | 91 | @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 92 | 93 | @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 94 | */ 95 | + (WBHttpRequest *)addGameScoreGain:(NSString*)userID 96 | withAccessToken:(NSString*)accessToken 97 | andOtherProperties:(NSDictionary*)otherProperties 98 | queue:(NSOperationQueue*)queue 99 | withCompletionHandler:(WBRequestHandler)handler; 100 | 101 | 102 | /*! 103 | @method 104 | 105 | @abstract 106 | 读取玩家游戏分数。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 107 | 108 | @param userID 当前授权用户的uid 109 | 110 | @param accessToken 当前授权用户的accessToken 111 | 112 | @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 113 | 114 | @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 115 | 116 | @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 117 | */ 118 | + (WBHttpRequest *)requestForGameScore:(NSString*)userID 119 | withAccessToken:(NSString*)accessToken 120 | andOtherProperties:(NSDictionary*)otherProperties 121 | queue:(NSOperationQueue*)queue 122 | withCompletionHandler:(WBRequestHandler)handler; 123 | 124 | /*! 125 | @method 126 | 127 | @abstract 128 | 读取玩家互粉好友游戏分数。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 129 | 130 | @param userID 当前授权用户的uid 131 | 132 | @param accessToken 当前授权用户的accessToken 133 | 134 | @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 135 | 136 | @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 137 | 138 | @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 139 | */ 140 | + (WBHttpRequest *)requestForFriendsGameScore:(NSString*)userID 141 | withAccessToken:(NSString*)accessToken 142 | andOtherProperties:(NSDictionary*)otherProperties 143 | queue:(NSOperationQueue*)queue 144 | withCompletionHandler:(WBRequestHandler)handler; 145 | 146 | /*! 147 | @method 148 | 149 | @abstract 150 | 读取玩家获取成就列表。 在http://open.weibo.com/wiki/%E6%B8%B8%E6%88%8F%E6%8E%A5%E5%8F%A3 中有关于该接口的细节说明。 151 | 152 | @param userID 当前授权用户的uid 153 | 154 | @param accessToken 当前授权用户的accessToken 155 | 156 | @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 157 | 158 | @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 159 | 160 | @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 161 | */ 162 | + (WBHttpRequest *)requestForGameAchievementGain:(NSString*)userID 163 | withAccessToken:(NSString*)accessToken 164 | andOtherProperties:(NSDictionary*)otherProperties 165 | queue:(NSOperationQueue*)queue 166 | withCompletionHandler:(WBRequestHandler)handler; 167 | 168 | @end 169 | -------------------------------------------------------------------------------- /ios/libWeiboSDK/WBHttpRequest+WeiboShare.h: -------------------------------------------------------------------------------- 1 | // 2 | // WBHttpRequest+WeiboShare.h 3 | // WeiboSDK 4 | // 5 | // Created by DannionQiu on 14/10/31. 6 | // Copyright (c) 2014年 SINA iOS Team. All rights reserved. 7 | // 8 | 9 | #import "WBHttpRequest.h" 10 | 11 | @class WBImageObject; 12 | 13 | @interface WBHttpRequest (WeiboShare) 14 | 15 | /*! 16 | @method 17 | 18 | @abstract 19 | 获得当前授权用户的微博id列表。 20 | 21 | @param userID 当前授权用户的uid 22 | 23 | @param accessToken 当前授权用户的accessToken 24 | 25 | @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 26 | 27 | @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 28 | 29 | @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 30 | */ 31 | + (WBHttpRequest *)requestForStatusIDsFromCurrentUser:(NSString*)userID 32 | withAccessToken:(NSString*)accessToken 33 | andOtherProperties:(NSDictionary*)otherProperties 34 | queue:(NSOperationQueue*)queue 35 | withCompletionHandler:(WBRequestHandler)handler; 36 | 37 | /*! 38 | @method 39 | 40 | @abstract 41 | 转发微博。转发微博id所对应的微博。 42 | 43 | @param statusID 微博id,微博的唯一标识符。 44 | 45 | @param text 添加的转发文本,内容不超过140个汉字,不填则默认为“转发微博”。 46 | 47 | @param accessToken 当前授权用户的accessToken 48 | 49 | @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 50 | 51 | @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 52 | 53 | @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 54 | */ 55 | + (WBHttpRequest *)requestForRepostAStatus:(NSString*)statusID 56 | repostText:(NSString*)text 57 | withAccessToken:(NSString*)accessToken 58 | andOtherProperties:(NSDictionary*)otherProperties 59 | queue:(NSOperationQueue*)queue 60 | withCompletionHandler:(WBRequestHandler)handler; 61 | 62 | /*! 63 | @method 64 | 65 | @abstract 66 | 发表一个微博(无图或者带一张图片的微博)。 67 | 68 | @param statusText 要发布的微博文本内容,内容不超过140个汉字。 69 | 70 | @param imageObject 要上传的图片,仅支持JPEG、GIF、PNG格式,图片大小小于5M。这个参数可为nil。由于只能传一张图片,若imageObject和url都有值,请看@caution。 71 | 72 | @param url 图片的URL地址,必须以http开头。这个参数可为nil,由于只能传一张图片,若imageObject和url都有值,请看@caution。 73 | 74 | @param accessToken 当前授权用户的accessToken 75 | 76 | @param otherProperties 一个NSDictionary字典,承载任意想额外添加到请求中的参数。 77 | 78 | @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 79 | 80 | @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 81 | 82 | @caution 注意,如果参数imageObject和url都有值,则发布带有imageObject所对应的图片,忽略url所对应的图片。 83 | */ 84 | + (WBHttpRequest *)requestForShareAStatus:(NSString*)statusText 85 | contatinsAPicture:(WBImageObject*)imageObject 86 | orPictureUrl:(NSString*)url 87 | withAccessToken:(NSString*)accessToken 88 | andOtherProperties:(NSDictionary*)otherProperties 89 | queue:(NSOperationQueue*)queue 90 | withCompletionHandler:(WBRequestHandler)handler; 91 | 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /ios/libWeiboSDK/WBHttpRequest+WeiboToken.h: -------------------------------------------------------------------------------- 1 | // 2 | // WBHttpRequest+WeiboToken.h 3 | // WeiboSDK 4 | // 5 | // Created by DannionQiu on 14/11/6. 6 | // Copyright (c) 2014年 SINA iOS Team. All rights reserved. 7 | // 8 | 9 | #import "WBHttpRequest.h" 10 | 11 | @interface WBHttpRequest (WeiboToken) 12 | /*! 13 | @method 14 | 15 | @abstract 16 | 使用RefreshToken去换取新的身份凭证AccessToken. 17 | 18 | @discussion 19 | 在SSO授权登录后,服务器会下发有效期为7天的refreshToken以及有效期为1天的AccessToken。 20 | 当有效期为1天的AccessToken过期时,可以调用该接口带着refreshToken信息区换取新的AccessToken。 21 | @param refreshToken refreshToken 22 | 23 | @param queue 指定发送请求的NSOperationQueue,如果这个参数为nil,则请求会发送在MainQueue( [NSOperationQueue mainQueue] )中。 24 | 25 | @param handler 完成请求后会回调handler,处理完成请求后的逻辑。 26 | */ 27 | + (WBHttpRequest *)requestForRenewAccessTokenWithRefreshToken:(NSString*)refreshToken 28 | queue:(NSOperationQueue*)queue 29 | withCompletionHandler:(WBRequestHandler)handler; 30 | @end 31 | -------------------------------------------------------------------------------- /ios/libWeiboSDK/WBHttpRequest+WeiboUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // WBHttpRequest+WeiboUser.h 3 | // WeiboSDK 4 | // 5 | // Created by DannionQiu on 14-9-23. 6 | // Copyright (c) 2014年 SINA iOS Team. All rights reserved. 7 | // 8 | 9 | #import "WBHttpRequest.h" 10 | 11 | @interface WBHttpRequest (WeiboUser) 12 | 13 | /*! 14 | @method 15 | 16 | @abstract 17 | Creates a request representing a Open API call to the "friendships/friends". 18 | 19 | @discussion 20 | Simplifies preparing a request and sending request to retrieve the user's friends. 21 | 22 | A successful Open API call will return an NSDictionary of objects which contanis an array of objects representing the 23 | user's friends. 24 | 25 | You can see more details about this API in http://open.weibo.com/wiki/2/friendships/friends/en 26 | 27 | @param currentUserID should be the current User's UserID which has been authorized. 28 | 29 | @param accessToken The token string. 30 | 31 | @param otherProperties Any additional properties for the Open API Request. 32 | 33 | @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] ). 34 | 35 | @param handler the comletion block which will be executed after received response from Open API server. 36 | */ 37 | + (WBHttpRequest *)requestForFriendsListOfUser:(NSString*)currentUserID 38 | withAccessToken:(NSString*)accessToken 39 | andOtherProperties:(NSDictionary*)otherProperties 40 | queue:(NSOperationQueue*)queue 41 | withCompletionHandler:(WBRequestHandler)handler; 42 | 43 | /*! 44 | @method 45 | 46 | @abstract 47 | Creates a request representing a Open API call to the "friendships/friends/ids". 48 | 49 | @discussion 50 | Simplifies preparing a request and sending request to retrieve the user's friends' UserID. 51 | 52 | A successful Open API call will return an NSDictionary of objects which contanis an array of NSString representing the 53 | user's friends' UserID. 54 | 55 | You can see more details about this API in http://open.weibo.com/wiki/2/friendships/friends/ids/en 56 | 57 | @param currentUserID should be the current User's UserID which has been authorized. 58 | 59 | @param accessToken The token string. 60 | 61 | @param otherProperties Any additional properties for the Open API Request. 62 | 63 | @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] ). 64 | 65 | @param handler the comletion block which will be executed after received response from Open API server. 66 | */ 67 | + (WBHttpRequest *)requestForFriendsUserIDListOfUser:(NSString*)currentUserID 68 | withAccessToken:(NSString*)accessToken 69 | andOtherProperties:(NSDictionary*)otherProperties 70 | queue:(NSOperationQueue*)queue 71 | withCompletionHandler:(WBRequestHandler)handler; 72 | 73 | 74 | /*! 75 | @method 76 | 77 | @abstract 78 | Creates a request representing a Open API call to the "friendships/friends/in_common". 79 | 80 | @discussion 81 | Simplifies preparing a request and sending request to retrieve the common friends list between two users.. 82 | 83 | A successful Open API call will return an NSDictionary of objects which contanis an array of objects representing the 84 | user's friends. 85 | 86 | You can see more details about this API in http://open.weibo.com/wiki/2/friendships/friends/in_common/en 87 | 88 | @param currentUserID should be the current User's UserID which has been authorized. 89 | 90 | @param accessToken The token string. 91 | 92 | @param otherProperties Any additional properties for the Open API Request. 93 | 94 | @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] ). 95 | 96 | @param handler the comletion block which will be executed after received response from Open API server. 97 | */ 98 | + (WBHttpRequest *)requestForCommonFriendsListBetweenUser:(NSString*)currentUserID 99 | andUser:(NSString*)anotherUserID 100 | withAccessToken:(NSString*)accessToken 101 | andOtherProperties:(NSDictionary*)otherProperties 102 | queue:(NSOperationQueue*)queue 103 | withCompletionHandler:(WBRequestHandler)handler; 104 | 105 | /*! 106 | @method 107 | 108 | @abstract 109 | Creates a request representing a Open API call to the "friendships/friends/bilateral". 110 | 111 | @discussion 112 | 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. 113 | 114 | A successful Open API call will return an NSDictionary of objects which contanis an array of objects representing the 115 | users that are following the specified user and are being followed by the specified user. 116 | 117 | You can see more details about this API in http://open.weibo.com/wiki/2/friendships/friends/bilateral/en 118 | 119 | @param currentUserID should be the current User's UserID which has been authorized. 120 | 121 | @param accessToken The token string. 122 | 123 | @param otherProperties Any additional properties for the Open API Request. 124 | 125 | @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] ). 126 | 127 | @param handler the comletion block which will be executed after received response from Open API server. 128 | */ 129 | + (WBHttpRequest *)requestForBilateralFriendsListOfUser:(NSString*)currentUserID 130 | withAccessToken:(NSString*)accessToken 131 | andOtherProperties:(NSDictionary*)otherProperties 132 | queue:(NSOperationQueue*)queue 133 | withCompletionHandler:(WBRequestHandler)handler; 134 | 135 | /*! 136 | @method 137 | 138 | @abstract 139 | Creates a request representing a Open API call to the "friendships/followers". 140 | 141 | @discussion 142 | Simplifies preparing a request and sending request to retrieve the user's followers. 143 | 144 | A successful Open API call will return an NSDictionary of objects which contanis an array of objects representing the 145 | user's followers. 146 | 147 | You can see more details about this API in http://open.weibo.com/wiki/2/friendships/followers/en 148 | 149 | @param currentUserID should be the current User's UserID which has been authorized. 150 | 151 | @param accessToken The token string. 152 | 153 | @param otherProperties Any additional properties for the Open API Request. 154 | 155 | @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] ). 156 | 157 | @param handler the comletion block which will be executed after received response from Open API server. 158 | */ 159 | + (WBHttpRequest *)requestForFollowersListOfUser:(NSString*)currentUserID 160 | withAccessToken:(NSString*)accessToken 161 | andOtherProperties:(NSDictionary*)otherProperties 162 | queue:(NSOperationQueue*)queue 163 | withCompletionHandler:(WBRequestHandler)handler; 164 | 165 | /*! 166 | @method 167 | 168 | @abstract 169 | Creates a request representing a Open API call to the "friendships/followers/ids". 170 | 171 | @discussion 172 | Simplifies preparing a request and sending request to retrieve the user's followers' UserID. 173 | 174 | A successful Open API call will return an NSDictionary of objects which contanis an array of NSString representing the 175 | user's followers' UserID. 176 | 177 | You can see more details about this API in http://open.weibo.com/wiki/2/friendships/followers/ids/en 178 | 179 | @param currentUserID should be the current User's UserID which has been authorized. 180 | 181 | @param accessToken The token string. 182 | 183 | @param otherProperties Any additional properties for the Open API Request. 184 | 185 | @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] ). 186 | 187 | @param handler the comletion block which will be executed after received response from Open API server. 188 | */ 189 | + (WBHttpRequest *)requestForFollowersUserIDListOfUser:(NSString*)currentUserID 190 | withAccessToken:(NSString*)accessToken 191 | andOtherProperties:(NSDictionary*)otherProperties 192 | queue:(NSOperationQueue*)queue 193 | withCompletionHandler:(WBRequestHandler)handler; 194 | 195 | /*! 196 | @method 197 | 198 | @abstract 199 | Creates a request representing a Open API call to the "friendships/followers/active". 200 | 201 | @discussion 202 | Simplifies preparing a request and sending request to retrieve the active(high quality) followers list of a user. 203 | 204 | 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. 205 | 206 | You can see more details about this API in http://open.weibo.com/wiki/2/friendships/followers/active/en 207 | 208 | @param currentUserID should be the current User's UserID which has been authorized. 209 | 210 | @param accessToken The token string. 211 | 212 | @param otherProperties Any additional properties for the Open API Request. 213 | 214 | @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] ). 215 | 216 | @param handler the comletion block which will be executed after received response from Open API server. 217 | */ 218 | + (WBHttpRequest *)requestForActiveFollowersListOfUser:(NSString*)currentUserID 219 | withAccessToken:(NSString*)accessToken 220 | andOtherProperties:(NSDictionary*)otherProperties 221 | queue:(NSOperationQueue*)queue 222 | withCompletionHandler:(WBRequestHandler)handler; 223 | 224 | /*! 225 | @method 226 | 227 | @abstract 228 | Creates a request representing a Open API call to the "friendships/friends_chain/followers". 229 | 230 | @discussion 231 | 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. 232 | 233 | 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. 234 | 235 | You can see more details about this API in http://open.weibo.com/wiki/2/friendships/friends_chain/followers/en 236 | 237 | @param currentUserID should be the current User's UserID which has been authorized. 238 | 239 | @param accessToken The token string. 240 | 241 | @param otherProperties Any additional properties for the Open API Request. 242 | 243 | @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] ). 244 | 245 | @param handler the comletion block which will be executed after received response from Open API server. 246 | */ 247 | + (WBHttpRequest *)requestForBilateralFollowersListOfUser:(NSString*)currentUserID 248 | withAccessToken:(NSString*)accessToken 249 | andOtherProperties:(NSDictionary*)otherProperties 250 | queue:(NSOperationQueue*)queue 251 | withCompletionHandler:(WBRequestHandler)handler; 252 | 253 | /*! 254 | @method 255 | 256 | @abstract 257 | Creates a request representing a Open API call to the "friendships/show". 258 | 259 | @discussion 260 | Simplifies preparing a request and sending request to retrieve the relationship of two users. 261 | 262 | A successful Open API call will return an NSDictionary of objects which contanis the relationship of two users. 263 | 264 | You can see more details about this API in http://open.weibo.com/wiki/2/friendships/show 265 | 266 | @param targetUserID a User ID 267 | 268 | @param sourceUserID a User ID 269 | 270 | @param accessToken The token string. 271 | 272 | @param otherProperties Any additional properties for the Open API Request. 273 | 274 | @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] ). 275 | 276 | @param handler the comletion block which will be executed after received response from Open API server. 277 | */ 278 | + (WBHttpRequest *)requestForFriendshipDetailBetweenTargetUser:(NSString*)targetUserID 279 | andSourceUser:(NSString*)sourceUserID 280 | withAccessToken:(NSString*)accessToken 281 | andOtherProperties:(NSDictionary*)otherProperties 282 | queue:(NSOperationQueue*)queue 283 | withCompletionHandler:(WBRequestHandler)handler; 284 | 285 | /*! 286 | @method 287 | 288 | @abstract 289 | Creates a request representing a Open API call to the "friendships/create". 290 | 291 | @discussion 292 | Simplifies preparing a request and sending request to Follow a user. 293 | 294 | A successful Open API call will return an object representing the user to be followed. 295 | 296 | You can see more details about this API in http://open.weibo.com/wiki/2/friendships/create/en 297 | 298 | @param theUserToBeFollowed the userID of the user which you want to follow. 299 | 300 | @param accessToken The token string. 301 | 302 | @param otherProperties Any additional properties for the Open API Request. 303 | 304 | @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] ). 305 | 306 | @param handler the comletion block which will be executed after received response from Open API server. 307 | */ 308 | + (WBHttpRequest *)requestForFollowAUser:(NSString*)theUserToBeFollowed 309 | withAccessToken:(NSString*)accessToken 310 | andOtherProperties:(NSDictionary*)otherProperties 311 | queue:(NSOperationQueue*)queue 312 | withCompletionHandler:(WBRequestHandler)handler; 313 | 314 | /*! 315 | @method 316 | 317 | @abstract 318 | Creates a request representing a Open API call to the "friendships/destroy". 319 | 320 | @discussion 321 | Simplifies preparing a request and sending request to cancel following a user. 322 | 323 | A successful Open API call will return an object representing the user to be followed. 324 | 325 | You can see more details about this API in http://open.weibo.com/wiki/2/friendships/destroy/en 326 | 327 | @param theUserThatYouDontLike the userID of the user which you want to cancel following. 328 | 329 | @param accessToken The token string. 330 | 331 | @param otherProperties Any additional properties for the Open API Request. 332 | 333 | @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] ). 334 | 335 | @param handler the comletion block which will be executed after received response from Open API server. 336 | */ 337 | + (WBHttpRequest *)requestForCancelFollowAUser:(NSString*)theUserThatYouDontLike 338 | withAccessToken:(NSString*)accessToken 339 | andOtherProperties:(NSDictionary*)otherProperties 340 | queue:(NSOperationQueue*)queue 341 | withCompletionHandler:(WBRequestHandler)handler; 342 | 343 | /*! 344 | @method 345 | 346 | @abstract 347 | Creates a request representing a Open API call to the "friendships/followers/destroy". 348 | 349 | @discussion 350 | Simplifies preparing a request and sending request to remove a follower of the authenticating user. 351 | 352 | A successful Open API call will return an object representing the user to be followed. 353 | 354 | 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 355 | 356 | You can see more details about this API in http://open.weibo.com/wiki/2/friendships/followers/destroy/en 357 | 358 | @param theUserThatYouDontLike the userID of the follower which you want to remove. 359 | 360 | @param accessToken The token string. 361 | 362 | @param otherProperties Any additional properties for the Open API Request. 363 | 364 | @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] ). 365 | 366 | @param handler the comletion block which will be executed after received response from Open API server. 367 | */ 368 | + (WBHttpRequest *)requestForRemoveFollowerUser:(NSString*)theUserThatYouDontLike 369 | withAccessToken:(NSString*)accessToken 370 | andOtherProperties:(NSDictionary*)otherProperties 371 | queue:(NSOperationQueue*)queue 372 | withCompletionHandler:(WBRequestHandler)handler; 373 | 374 | /*! 375 | @method 376 | 377 | @abstract 378 | Creates a request representing a Open API call to the "messages/invite". 379 | 380 | @discussion 381 | Simplifies preparing a request and sending request to send invitation to a bilateral friend of the authenticating user. 382 | 383 | A successful Open API call will return an NSDictionary of objects which contanis objects representing sender and receiver and other invitation details. 384 | 385 | You can see more details about this API in http://open.weibo.com/wiki/2/messages/invite 386 | 387 | @param theUserThatShouldBeYourBilateralFriend the userID of the follower which you want to remove. 388 | 389 | @param accessToken The token string. 390 | 391 | @param text The text content in your invitation message. should not be nil. 392 | 393 | @param url The url in your invitation message. can be nil. 394 | 395 | @param logoUrl The logoUrl in your invitation message. can be nil. 396 | 397 | @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] ). 398 | 399 | @param handler the comletion block which will be executed after received response from Open API server. 400 | */ 401 | + (WBHttpRequest *)requestForInviteBilateralFriend:(NSString*)theUserThatShouldBeYourBilateralFriend 402 | withAccessToken:(NSString*)accessToken 403 | inviteText:(NSString*)text 404 | inviteUrl:(NSString*)url 405 | inviteLogoUrl:(NSString*)logoUrl 406 | queue:(NSOperationQueue*)queue 407 | withCompletionHandler:(WBRequestHandler)handler; 408 | 409 | 410 | /*! 411 | @method 412 | 413 | @abstract 414 | Creates a request representing a Open API call to the "users/show". 415 | 416 | @discussion 417 | Simplifies preparing a request and sending request to retrieve user profile by user ID.. 418 | 419 | A successful Open API call will return a object representing the user profile by user ID. 420 | 421 | You can see more details about this API in http://open.weibo.com/wiki/2/users/show/en 422 | 423 | @param aUserID a User ID. 424 | 425 | @param accessToken The token string. 426 | 427 | @param otherProperties Any additional properties for the Open API Request. 428 | 429 | @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] ). 430 | 431 | @param handler the comletion block which will be executed after received response from Open API server. 432 | */ 433 | + (WBHttpRequest *)requestForUserProfile:(NSString*)aUserID 434 | withAccessToken:(NSString*)accessToken 435 | andOtherProperties:(NSDictionary*)otherProperties 436 | queue:(NSOperationQueue*)queue 437 | withCompletionHandler:(WBRequestHandler)handler; 438 | 439 | @end 440 | -------------------------------------------------------------------------------- /ios/libWeiboSDK/WBHttpRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // WBHttpRequest.h 3 | // WeiboSDK 4 | // 5 | // Created by DannionQiu on 14-9-18. 6 | // Copyright (c) 2014年 SINA iOS Team. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | #pragma mark - WBHttpRequest and WBHttpRequestDelegate 13 | @class WBHttpRequest; 14 | 15 | /** 16 | 接收并处理来自微博sdk对于网络请求接口的调用响应 以及openAPI 17 | 如inviteFriend、logOutWithToken的请求 18 | */ 19 | @protocol WBHttpRequestDelegate 20 | 21 | /** 22 | 收到一个来自微博Http请求的响应 23 | 24 | @param response 具体的响应对象 25 | */ 26 | @optional 27 | - (void)request:(WBHttpRequest *)request didReceiveResponse:(NSURLResponse *)response; 28 | 29 | /** 30 | 收到一个来自微博Http请求失败的响应 31 | 32 | @param error 错误信息 33 | */ 34 | @optional 35 | - (void)request:(WBHttpRequest *)request didFailWithError:(NSError *)error; 36 | 37 | /** 38 | 收到一个来自微博Http请求的网络返回 39 | 40 | @param result 请求返回结果 41 | */ 42 | @optional 43 | - (void)request:(WBHttpRequest *)request didFinishLoadingWithResult:(NSString *)result; 44 | 45 | /** 46 | 收到一个来自微博Http请求的网络返回 47 | 48 | @param data 请求返回结果 49 | */ 50 | @optional 51 | - (void)request:(WBHttpRequest *)request didFinishLoadingWithDataResult:(NSData *)data; 52 | 53 | /** 54 | 收到快速SSO授权的重定向 55 | 56 | @param URI 57 | */ 58 | @optional 59 | - (void)request:(WBHttpRequest *)request didReciveRedirectResponseWithURI:(NSURL *)redirectUrl; 60 | 61 | @end 62 | 63 | 64 | /** 65 | 微博封装Http请求的消息结构 66 | 67 | */ 68 | @interface WBHttpRequest : NSObject 69 | { 70 | NSURLConnection *connection; 71 | NSMutableData *responseData; 72 | } 73 | 74 | /** 75 | 用户自定义请求地址URL 76 | */ 77 | @property (nonatomic, strong) NSString *url; 78 | 79 | /** 80 | 用户自定义请求方式 81 | 82 | 支持"GET" "POST" 83 | */ 84 | @property (nonatomic, strong) NSString *httpMethod; 85 | 86 | /** 87 | 用户自定义请求参数字典 88 | */ 89 | @property (nonatomic, strong) NSDictionary *params; 90 | 91 | /** 92 | WBHttpRequestDelegate对象,用于接收微博SDK对于发起的接口请求的请求的响应 93 | */ 94 | @property (nonatomic, weak) id delegate; 95 | 96 | /** 97 | 用户自定义TAG 98 | 99 | 用于区分回调Request 100 | */ 101 | @property (nonatomic, strong) NSString* tag; 102 | 103 | /** 104 | 统一HTTP请求接口 105 | 调用此接口后,将发送一个HTTP网络请求 106 | @param url 请求url地址 107 | @param httpMethod 支持"GET" "POST" 108 | @param params 向接口传递的参数结构 109 | @param delegate WBHttpRequestDelegate对象,用于接收微博SDK对于发起的接口请求的请求的响应 110 | @param tag 用户自定义TAG,将通过回调WBHttpRequest实例的tag属性返回 111 | */ 112 | + (WBHttpRequest *)requestWithURL:(NSString *)url 113 | httpMethod:(NSString *)httpMethod 114 | params:(NSDictionary *)params 115 | delegate:(id)delegate 116 | withTag:(NSString *)tag; 117 | 118 | /** 119 | 统一微博Open API HTTP请求接口 120 | 调用此接口后,将发送一个HTTP网络请求(用于访问微博open api) 121 | @param accessToken 应用获取到的accessToken,用于身份验证 122 | @param url 请求url地址 123 | @param httpMethod 支持"GET" "POST" 124 | @param params 向接口传递的参数结构 125 | @param delegate WBHttpRequestDelegate对象,用于接收微博SDK对于发起的接口请求的请求的响应 126 | @param tag 用户自定义TAG,将通过回调WBHttpRequest实例的tag属性返回 127 | */ 128 | + (WBHttpRequest *)requestWithAccessToken:(NSString *)accessToken 129 | url:(NSString *)url 130 | httpMethod:(NSString *)httpMethod 131 | params:(NSDictionary *)params 132 | delegate:(id)delegate 133 | withTag:(NSString *)tag; 134 | 135 | 136 | 137 | /** 138 | 取消网络请求接口 139 | 调用此接口后,将取消当前网络请求,建议同时[WBHttpRequest setDelegate:nil]; 140 | 注意:该方法只对使用delegate的request方法有效。无法取消任何使用block的request的网络请求接口。 141 | */ 142 | - (void)disconnect; 143 | 144 | #pragma mark - block extension 145 | 146 | typedef void (^WBRequestHandler)(WBHttpRequest *httpRequest, 147 | id result, 148 | NSError *error); 149 | 150 | /** 151 | 统一微博Open API HTTP请求接口 152 | 调用此接口后,将发送一个HTTP网络请求(用于访问微博open api) 153 | @param url 请求url地址 154 | @param httpMethod 支持"GET" "POST" 155 | @param params 向接口传递的参数结构 156 | @param queue 发起请求的NSOperationQueue对象,如queue为nil,则在主线程([NSOperationQueue mainQueue])发起请求。 157 | @param handler 接口请求返回调用的block方法 158 | */ 159 | + (WBHttpRequest *)requestWithURL:(NSString *)url 160 | httpMethod:(NSString *)httpMethod 161 | params:(NSDictionary *)params 162 | queue:(NSOperationQueue*)queue 163 | withCompletionHandler:(WBRequestHandler)handler; 164 | 165 | 166 | /** 167 | 统一HTTP请求接口 168 | 调用此接口后,将发送一个HTTP网络请求 169 | @param url 请求url地址 170 | @param httpMethod 支持"GET" "POST" 171 | @param params 向接口传递的参数结构 172 | @param queue 发起请求的NSOperationQueue对象,如queue为nil,则在主线程([NSOperationQueue mainQueue])发起请求。 173 | @param handler 接口请求返回调用的block方法 174 | */ 175 | + (WBHttpRequest *)requestWithAccessToken:(NSString *)accessToken 176 | url:(NSString *)url 177 | httpMethod:(NSString *)httpMethod 178 | params:(NSDictionary *)params 179 | queue:(NSOperationQueue*)queue 180 | withCompletionHandler:(WBRequestHandler)handler; 181 | 182 | @end 183 | -------------------------------------------------------------------------------- /ios/libWeiboSDK/WBSDKBasicButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // WBSDKBasicButton.h 3 | // WeiboSDK 4 | // 5 | // Created by DannionQiu on 14/10/24. 6 | // Copyright (c) 2014年 SINA iOS Team. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class WBSDKBasicButton; 12 | typedef void (^WBSDKButtonHandler)(WBSDKBasicButton *button, 13 | BOOL isSuccess, 14 | NSDictionary *resultDict); 15 | 16 | @interface WBSDKBasicButton : UIButton 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ios/libWeiboSDK/WBSDKCommentButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // WBSDKCommentButton.h 3 | // WeiboSDK 4 | // 5 | // Created by DannionQiu on 14/10/26. 6 | // Copyright (c) 2014年 SINA iOS Team. All rights reserved. 7 | // 8 | 9 | #import "WBSDKBasicButton.h" 10 | 11 | @interface WBSDKCommentButton : WBSDKBasicButton 12 | 13 | /** 14 | 初始化一个社会化评论按钮 15 | @param frame 按钮的frame值 16 | @param accessToken 用户授权后获取的Token 17 | @param keyWord 社会化评论的热点词 18 | @param urlString 社会化评论链接,可传空 19 | @param category 领域ID, 此参数为必选参数。 20 | @param handler 回调函数,当用户点击按钮,进行完与社会化评论组件相关的交互之后,回调的函数。 21 | */ 22 | - (id)initWithFrame:(CGRect)frame 23 | accessToken:(NSString*)accessToken 24 | keyword:(NSString*)keyWord 25 | urlString:(NSString*)urlString 26 | category:(NSString*)category 27 | completionHandler:(WBSDKButtonHandler)handler; 28 | 29 | @property (nonatomic, strong)NSString* keyWord; 30 | @property (nonatomic, strong)NSString* accessToken; 31 | @property (nonatomic, strong)NSString* urlString; 32 | @property (nonatomic, strong)NSString* category; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /ios/libWeiboSDK/WBSDKRelationshipButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // WBSDKRelationshipButton.h 3 | // WeiboSDK 4 | // 5 | // Created by DannionQiu on 14/10/26. 6 | // Copyright (c) 2014年 SINA iOS Team. All rights reserved. 7 | // 8 | 9 | #import "WBSDKBasicButton.h" 10 | 11 | enum 12 | { 13 | WBSDKRelationshipButtonStateFollow, 14 | WBSDKRelationshipButtonStateUnfollow 15 | }; 16 | typedef NSUInteger WBSDKRelationshipButtonState; 17 | 18 | 19 | 20 | @interface WBSDKRelationshipButton : WBSDKBasicButton 21 | 22 | /** 23 | 初始化一个关注组件按钮 24 | @param frame 按钮的frame值 25 | @param accessToken 用户授权后获取的Token 26 | @param currentUserID 当前用户的uid值 27 | @param followerUserID 希望当前用户加关注的用户uid值 28 | @param handler 回调函数,当用户点击按钮,进行完关注组件相关的交互之后,回调的函数。 29 | */ 30 | - (id)initWithFrame:(CGRect)frame 31 | accessToken:(NSString*)accessToken 32 | currentUser:(NSString*)currentUserID 33 | followUser:(NSString*)followerUserID 34 | completionHandler:(WBSDKButtonHandler)handler; 35 | 36 | @property (nonatomic, strong)NSString* accessToken; 37 | @property (nonatomic, strong)NSString* currentUserID; 38 | @property (nonatomic, strong)NSString* followUserID; 39 | 40 | 41 | @property (nonatomic, assign)WBSDKRelationshipButtonState currentRelationShip; 42 | 43 | 44 | /** 45 | 获取最新的关注状态 46 | 该方法会调用OpenApi,获取当前用户与目标用户之间的关注状态,并将按钮的状态改变为正确的状态。 47 | */ 48 | - (void)checkCurrentRelationship; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/alert_error_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/alert_error_icon@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/alert_success_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/alert_success_icon@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/close.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/close@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/close@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_big_blue@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_big_blue@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_big_blue_disable@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_big_blue_disable@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_big_blue_highlighted@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_big_blue_highlighted@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_white.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_white@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_white@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_white_highlighted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_white_highlighted.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_white_highlighted@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/common_button_white_highlighted@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/common_icon_arrow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/common_icon_arrow@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/compose_keyboardbutton_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/compose_keyboardbutton_background.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/compose_keyboardbutton_background@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/compose_keyboardbutton_background@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/compose_toolbar_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/compose_toolbar_background.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/compose_toolbar_background@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/compose_toolbar_background@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/empty_failed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/empty_failed.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/empty_failed@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/empty_failed@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/login_background@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/login_background@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/login_country_background@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/login_country_background@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/login_country_background_highlighted@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/login_country_background_highlighted@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/navigationbar_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/navigationbar_background.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/navigationbar_background@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/navigationbar_background@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/navigationbar_background_os7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/navigationbar_background_os7.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/navigationbar_background_os7@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/navigationbar_background_os7@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/progresshud_background@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/progresshud_background@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/sdk_weibo_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/sdk_weibo_logo.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/sdk_weibo_logo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/sdk_weibo_logo@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/sdk_weibo_logo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/sdk_weibo_logo@3x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/timeline_relationship_icon_addattention.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/timeline_relationship_icon_addattention.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/timeline_relationship_icon_addattention@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/timeline_relationship_icon_addattention@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/timeline_relationship_icon_addattention@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/timeline_relationship_icon_addattention@3x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/timeline_relationship_icon_attention.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/timeline_relationship_icon_attention.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/timeline_relationship_icon_attention@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/timeline_relationship_icon_attention@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/timeline_relationship_icon_attention@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/timeline_relationship_icon_attention@3x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/verify_code_button@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/verify_code_button@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/verify_code_button@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/verify_code_button@3x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/verify_code_button_highlighted@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/verify_code_button_highlighted@2x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/images/verify_code_button_highlighted@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/images/verify_code_button_highlighted@3x.png -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/others/countryList: -------------------------------------------------------------------------------- 1 | {"香港地区":{"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"]}}} -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.bundle/others/mfp.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/WeiboSDK.bundle/others/mfp.cer -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboSDK.h: -------------------------------------------------------------------------------- 1 | // 2 | // WeiboSDKHeaders.h 3 | // WeiboSDKDemo 4 | // 5 | // Created by Wade Cheng on 4/3/13. 6 | // Copyright (c) 2013 SINA iOS Team. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | #import "WBHttpRequest.h" 13 | #import "WBHttpRequest+WeiboUser.h" 14 | #import "WBHttpRequest+WeiboShare.h" 15 | #import "WBHttpRequest+WeiboToken.h" 16 | #import "WBHttpRequest+WeiboGame.h" 17 | #import "WBSDKRelationshipButton.h" 18 | #import "WBSDKCommentButton.h" 19 | 20 | 21 | typedef NS_ENUM(NSInteger, WeiboSDKResponseStatusCode) 22 | { 23 | WeiboSDKResponseStatusCodeSuccess = 0,//成功 24 | WeiboSDKResponseStatusCodeUserCancel = -1,//用户取消发送 25 | WeiboSDKResponseStatusCodeSentFail = -2,//发送失败 26 | WeiboSDKResponseStatusCodeAuthDeny = -3,//授权失败 27 | WeiboSDKResponseStatusCodeUserCancelInstall = -4,//用户取消安装微博客户端 28 | WeiboSDKResponseStatusCodePayFail = -5,//支付失败 29 | WeiboSDKResponseStatusCodeShareInSDKFailed = -8,//分享失败 详情见response UserInfo 30 | WeiboSDKResponseStatusCodeUnsupport = -99,//不支持的请求 31 | WeiboSDKResponseStatusCodeUnknown = -100, 32 | }; 33 | 34 | @protocol WeiboSDKDelegate; 35 | @protocol WBHttpRequestDelegate; 36 | @class WBBaseRequest; 37 | @class WBBaseResponse; 38 | @class WBMessageObject; 39 | @class WBImageObject; 40 | @class WBBaseMediaObject; 41 | @class WBHttpRequest; 42 | @class WBOrderObject; 43 | /** 44 | 微博SDK接口类 45 | */ 46 | @interface WeiboSDK : NSObject 47 | 48 | /** 49 | 检查用户是否安装了微博客户端程序 50 | @return 已安装返回YES,未安装返回NO 51 | */ 52 | + (BOOL)isWeiboAppInstalled; 53 | 54 | /** 55 | 检查用户是否可以通过微博客户端进行分享 56 | @return 可以使用返回YES,不可以使用返回NO 57 | */ 58 | + (BOOL)isCanShareInWeiboAPP; 59 | 60 | /** 61 | 检查用户是否可以使用微博客户端进行SSO授权 62 | @return 可以使用返回YES,不可以使用返回NO 63 | */ 64 | + (BOOL)isCanSSOInWeiboApp; 65 | 66 | /** 67 | 打开微博客户端程序 68 | @return 成功打开返回YES,失败返回NO 69 | */ 70 | + (BOOL)openWeiboApp; 71 | 72 | /** 73 | 获取微博客户端程序的itunes安装地址 74 | @return 微博客户端程序的itunes安装地址 75 | */ 76 | + (NSString *)getWeiboAppInstallUrl; 77 | 78 | /** 79 | 获取当前微博客户端程序所支持的SDK最高版本 80 | @return 当前微博客户端程序所支持的SDK最高版本号,返回 nil 表示未安装微博客户端 81 | */ 82 | + (NSString *)getWeiboAppSupportMaxSDKVersion __attribute__((deprecated)); 83 | 84 | /** 85 | 获取当前微博SDK的版本号 86 | @return 当前微博SDK的版本号 87 | */ 88 | + (NSString *)getSDKVersion; 89 | 90 | 91 | extern NSString * const WeiboSDKGetAidSucessNotification; 92 | extern NSString * const WeiboSDKGetAidFailNotification; 93 | /** 94 | 获取当前微博SDK的aid 95 | 返回的aid值可能为 nil ,当值为 nil 时会尝试获取 aid 值。 96 | 当获取成功( aid 值变为有效值)时,SDK会发出名为 WeiboSDKGetAidSucessNotification 的通知,通知中带有 aid 值。 97 | 当获取失败时,SDK会发出名为 WeiboSDKGetAidFailNotification 的通知,通知中带有 NSError 对象。 98 | @return aid 用于广告的与设备信息相关的标识符 99 | */ 100 | + (NSString *)getWeiboAid; 101 | 102 | /** 103 | 向微博客户端程序注册第三方应用 104 | @param appKey 微博开放平台第三方应用appKey 105 | @return 注册成功返回YES,失败返回NO 106 | */ 107 | + (BOOL)registerApp:(NSString *)appKey; 108 | 109 | /** 110 | 处理微博客户端程序通过URL启动第三方应用时传递的数据 111 | 112 | 需要在 application:openURL:sourceApplication:annotation:或者application:handleOpenURL中调用 113 | @param url 启动第三方应用的URL 114 | @param delegate WeiboSDKDelegate对象,用于接收微博触发的消息 115 | @see WeiboSDKDelegate 116 | */ 117 | + (BOOL)handleOpenURL:(NSURL *)url delegate:(id)delegate; 118 | 119 | /** 120 | 发送请求给微博客户端程序,并切换到微博 121 | 122 | 请求发送给微博客户端程序之后,微博客户端程序会进行相关的处理,处理完成之后一定会调用 [WeiboSDKDelegate didReceiveWeiboResponse:] 方法将处理结果返回给第三方应用 123 | 124 | @param request 具体的发送请求 125 | 126 | @see [WeiboSDKDelegate didReceiveWeiboResponse:] 127 | @see WBBaseResponse 128 | */ 129 | + (BOOL)sendRequest:(WBBaseRequest *)request; 130 | 131 | /** 132 | 收到微博客户端程序的请求后,发送对应的应答给微博客户端端程序,并切换到微博 133 | 134 | 第三方应用收到微博的请求后,异步处理该请求,完成后必须调用该函数将应答返回给微博 135 | 136 | @param response 具体的应答内容 137 | @see WBBaseRequest 138 | */ 139 | + (BOOL)sendResponse:(WBBaseResponse *)response; 140 | 141 | /** 142 | 设置WeiboSDK的调试模式 143 | 144 | 当开启调试模式时,WeiboSDK会在控制台输出详细的日志信息,开发者可以据此调试自己的程序。默认为 NO 145 | @param enabled 开启或关闭WeiboSDK的调试模式 146 | */ 147 | + (void)enableDebugMode:(BOOL)enabled; 148 | 149 | /** 150 | 取消授权,登出接口 151 | 调用此接口后,token将失效 152 | @param token 第三方应用之前申请的Token 153 | @param delegate WBHttpRequestDelegate对象,用于接收微博SDK对于发起的接口请求的请求的响应 154 | @param tag 用户自定义TAG,将通过回调WBHttpRequest实例的tag属性返回 155 | 156 | */ 157 | + (void)logOutWithToken:(NSString *)token delegate:(id)delegate withTag:(NSString*)tag; 158 | 159 | /** 160 | 邀请好友使用应用 161 | 调用此接口后,将发送私信至好友,成功将返回微博标准私信结构 162 | @param data 邀请数据。必须为json字串的形式,必须做URLEncode,采用UTF-8编码。 163 | data参数支持的参数: 164 | 参数名称 值的类型 是否必填 说明描述 165 | text string true 要回复的私信文本内容。文本大小必须小于300个汉字。 166 | url string false 邀请点击后跳转链接。默认为当前应用地址。 167 | invite_logo string false 邀请Card展示时的图标地址,大小必须为80px X 80px,仅支持PNG、JPG格式。默认为当前应用logo地址。 168 | @param uid 被邀请人,需为当前用户互粉好友。 169 | @param access_token 第三方应用之前申请的Token 170 | @param delegate WBHttpRequestDelegate对象,用于接收微博SDK对于发起的接口请求的请求的响应 171 | @param tag 用户自定义TAG,将通过回调WBHttpRequest实例的tag属性返回 172 | 173 | */ 174 | + (void)inviteFriend:(NSString* )data withUid:(NSString *)uid withToken:(NSString *)access_token delegate:(id)delegate withTag:(NSString*)tag; 175 | 176 | /* 177 | 第三方调用微博短信注册或者登陆 178 | @param navTitle 为登陆页navigationBar的title,如果为空的话,默认为“验证码登陆” 179 | */ 180 | + (void)messageRegister:(NSString *)navTitle; 181 | @end 182 | 183 | /** 184 | 接收并处理来至微博客户端程序的事件消息 185 | */ 186 | @protocol WeiboSDKDelegate 187 | 188 | /** 189 | 收到一个来自微博客户端程序的请求 190 | 191 | 收到微博的请求后,第三方应用应该按照请求类型进行处理,处理完后必须通过 [WeiboSDK sendResponse:] 将结果回传给微博 192 | @param request 具体的请求对象 193 | */ 194 | - (void)didReceiveWeiboRequest:(WBBaseRequest *)request; 195 | 196 | /** 197 | 收到一个来自微博客户端程序的响应 198 | 199 | 收到微博的响应后,第三方应用可以通过响应类型、响应的数据和 WBBaseResponse.userInfo 中的数据完成自己的功能 200 | @param response 具体的响应对象 201 | */ 202 | - (void)didReceiveWeiboResponse:(WBBaseResponse *)response; 203 | 204 | @end 205 | 206 | 207 | #pragma mark - DataTransferObject and Base Request/Response 208 | 209 | /** 210 | 微博客户端程序和第三方应用之间传输数据信息的基类 211 | */ 212 | @interface WBDataTransferObject : NSObject 213 | 214 | /** 215 | 自定义信息字典,用于数据传输过程中存储相关的上下文环境数据 216 | 217 | 第三方应用给微博客户端程序发送 request 时,可以在 userInfo 中存储请求相关的信息。 218 | 219 | @warning userInfo中的数据必须是实现了 `NSCoding` 协议的对象,必须保证能序列化和反序列化 220 | @warning 序列化后的数据不能大于10M 221 | */ 222 | @property (nonatomic, strong) NSDictionary *userInfo; 223 | 224 | 225 | /** 226 | 发送该数据对象的SDK版本号 227 | 228 | 如果数据对象是自己生成的,则sdkVersion为当前SDK的版本号;如果是接收到的数据对象,则sdkVersion为数据发送方SDK版本号 229 | */ 230 | @property (strong, nonatomic, readonly) NSString *sdkVersion; 231 | 232 | 233 | /** 234 | 当用户没有安装微博客户端程序时是否提示用户打开微博安装页面 235 | 236 | 如果设置为YES,当用户未安装微博时会弹出Alert询问用户是否要打开微博App的安装页面。默认为YES 237 | */ 238 | @property (nonatomic, assign) BOOL shouldOpenWeiboAppInstallPageIfNotInstalled; 239 | 240 | 241 | @end 242 | 243 | 244 | /** 245 | 微博SDK所有请求类的基类 246 | */ 247 | @interface WBBaseRequest : WBDataTransferObject 248 | 249 | /** 250 | 返回一个 WBBaseRequest 对象 251 | 252 | @return 返回一个*自动释放的*WBBaseRequest对象 253 | */ 254 | + (id)request; 255 | 256 | @end 257 | 258 | 259 | /** 260 | 微博SDK所有响应类的基类 261 | */ 262 | @interface WBBaseResponse : WBDataTransferObject 263 | 264 | /** 265 | 对应的 request 中的自定义信息字典 266 | 267 | 如果当前 response 是由微博客户端响应给第三方应用的,则 requestUserInfo 中会包含原 request.userInfo 中的所有数据 268 | 269 | @see WBBaseRequest.userInfo 270 | */ 271 | @property (strong, nonatomic, readonly) NSDictionary *requestUserInfo; 272 | 273 | /** 274 | 响应状态码 275 | 276 | 第三方应用可以通过statusCode判断请求的处理结果 277 | */ 278 | @property (nonatomic, assign) WeiboSDKResponseStatusCode statusCode; 279 | 280 | /** 281 | 返回一个 WBBaseResponse 对象 282 | 283 | @return 返回一个*自动释放的*WBBaseResponse对象 284 | */ 285 | + (id)response; 286 | 287 | @end 288 | 289 | #pragma mark - Authorize Request/Response 290 | 291 | /** 292 | 第三方应用向微博客户端请求认证的消息结构 293 | 294 | 第三方应用向微博客户端申请认证时,需要调用 [WeiboSDK sendRequest:] 函数, 向微博客户端发送一个 WBAuthorizeRequest 的消息结构。 295 | 微博客户端处理完后会向第三方应用发送一个结构为 WBAuthorizeResponse 的处理结果。 296 | */ 297 | @interface WBAuthorizeRequest : WBBaseRequest 298 | 299 | /** 300 | 微博开放平台第三方应用授权回调页地址,默认为`http://` 301 | 302 | 参考 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 303 | 304 | @warning 必须保证和在微博开放平台应用管理界面配置的“授权回调页”地址一致,如未进行配置则默认为`http://` 305 | @warning 不能为空,长度小于1K 306 | */ 307 | @property (nonatomic, strong) NSString *redirectURI; 308 | 309 | /** 310 | 微博开放平台第三方应用scope,多个scrope用逗号分隔 311 | 312 | 参考 http://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6%E8%AF%B4%E6%98%8E#scope 313 | 314 | @warning 长度小于1K 315 | */ 316 | @property (nonatomic, strong) NSString *scope; 317 | 318 | /** 319 | 当用户没有安装微博客户端或微博客户端过低无法支持SSO的时候是否弹出SDK自带的Webview进行授权 320 | 321 | 如果设置为YES,当用户没有安装微博客户端或微博客户端过低无法支持SSO的时候会自动弹出SDK自带的Webview进行授权。 322 | 323 | 如果设置为NO,会根据 shouldOpenWeiboAppInstallPageIfNotInstalled 属性判断是否弹出安装/更新微博的对话框 324 | 325 | 默认为YES 326 | */ 327 | @property (nonatomic, assign) BOOL shouldShowWebViewForAuthIfCannotSSO; 328 | 329 | @end 330 | 331 | 332 | /** 333 | 微博客户端处理完第三方应用的认证申请后向第三方应用回送的处理结果 334 | 335 | WBAuthorizeResponse 结构中仅包含常用的 userID 、accessToken 和 expirationDate 信息,其他的认证信息(比如部分应用可以获取的 refresh_token 信息)会统一存放到 userInfo 中 336 | */ 337 | @interface WBAuthorizeResponse : WBBaseResponse 338 | 339 | /** 340 | 用户ID 341 | */ 342 | @property (nonatomic, strong) NSString *userID; 343 | 344 | /** 345 | 认证口令 346 | */ 347 | @property (nonatomic, strong) NSString *accessToken; 348 | 349 | /** 350 | 认证过期时间 351 | */ 352 | @property (nonatomic, strong) NSDate *expirationDate; 353 | 354 | /** 355 | 当认证口令过期时用于换取认证口令的更新口令 356 | */ 357 | @property (nonatomic, strong) NSString *refreshToken; 358 | 359 | @end 360 | 361 | #pragma mark - ProvideMessageForWeibo Request/Response 362 | 363 | /** 364 | 微博客户端向第三方程序请求提供内容的消息结构 365 | */ 366 | @interface WBProvideMessageForWeiboRequest : WBBaseRequest 367 | 368 | @end 369 | 370 | /** 371 | 微博客户端向第三方应用请求提供内容,第三方应用向微博客户端返回的消息结构 372 | */ 373 | @interface WBProvideMessageForWeiboResponse : WBBaseResponse 374 | 375 | /** 376 | 提供给微博客户端的消息 377 | */ 378 | @property (nonatomic, strong) WBMessageObject *message; 379 | 380 | /** 381 | 返回一个 WBProvideMessageForWeiboResponse 对象 382 | @param message 需要回送给微博客户端程序的消息对象 383 | @return 返回一个*自动释放的*WBProvideMessageForWeiboResponse对象 384 | */ 385 | + (id)responseWithMessage:(WBMessageObject *)message; 386 | 387 | @end 388 | 389 | #pragma mark - SendMessageToWeibo Request/Response 390 | 391 | /** 392 | 第三方应用发送消息至微博客户端程序的消息结构体 393 | */ 394 | @interface WBSendMessageToWeiboRequest : WBBaseRequest 395 | 396 | /** 397 | 发送给微博客户端的消息 398 | */ 399 | @property (nonatomic, strong) WBMessageObject *message; 400 | 401 | /** 402 | 返回一个 WBSendMessageToWeiboRequest 对象 403 | 此方法生成对象被[WeiboSDK sendRequest:]会唤起微博客户端的发布器进行分享,如果未安装微博客户端或客户端版本太低 404 | 会根据 shouldOpenWeiboAppInstallPageIfNotInstalled 属性判断是否弹出安装/更新微博的对话框 405 | @param message 需要发送给微博客户端的消息对象 406 | @return 返回一个*自动释放的*WBSendMessageToWeiboRequest对象 407 | */ 408 | + (id)requestWithMessage:(WBMessageObject *)message; 409 | 410 | /** 411 | 返回一个 WBSendMessageToWeiboRequest 对象 412 | 413 | 当用户安装了可以支持微博客户端內分享的微博客户端时,会自动唤起微博并分享 414 | 当用户没有安装微博客户端或微博客户端过低无法支持通过客户端內分享的时候会自动唤起SDK內微博发布器 415 | 416 | @param message 需要发送给微博的消息对象 417 | @param authRequest 授权相关信息,与access_token二者至少有一个不为空,当access_token为空并且需要弹出SDK內发布器时会通过此信息先进行授权后再分享 418 | @param access_token 第三方应用之前申请的Token,当此值不为空并且无法通过客户端分享的时候,会使用此token进行分享。 419 | @return 返回一个*自动释放的*WBSendMessageToWeiboRequest对象 420 | */ 421 | + (id)requestWithMessage:(WBMessageObject *)message 422 | authInfo:(WBAuthorizeRequest *)authRequest 423 | access_token:(NSString *)access_token; 424 | 425 | @end 426 | 427 | /** 428 | WBSendMessageToWeiboResponse 429 | */ 430 | @interface WBSendMessageToWeiboResponse : WBBaseResponse 431 | 432 | /** 433 | 可能在分享过程中用户进行了授权操作,当此值不为空时,为用户相应授权信息 434 | */ 435 | @property (nonatomic,strong) WBAuthorizeResponse *authResponse; 436 | @end 437 | 438 | #pragma mark - AppRecomend Request/Response 439 | 440 | /** 441 | 第三方应用私信好友推荐app的请求 442 | */ 443 | @interface WBSDKAppRecommendRequest : WBBaseRequest 444 | /** 445 | 返回一个 WBSDKAppRecommendRequest 对象 446 | 447 | @param uids 为推荐的好友列表,为空时跳转到用户自选的页面 448 | @param access_token 第三方应用之前申请的Token,当此值不为空并且无法通过客户端分享的时候,会使用此token私信。 449 | @return 返回一个*自动释放的*WBSDKAppRecommendRequest对象 450 | */ 451 | + (id)requestWithUIDs:(NSArray *)uids access_token:(NSString *)access_token; 452 | 453 | /** 454 | 私信对象列表 455 | */ 456 | @property (nonatomic, strong) NSArray* uids; 457 | /** 458 | 用于认证的Token 459 | */ 460 | @property (nonatomic, strong) NSString *access_token; 461 | @end 462 | 463 | /** 464 | 第三方应用私信好友推荐app的响应 465 | 466 | WBSDKAppRecommendResponse 结构中仅包含常用的 userID 、accessToken 和 expirationDate 信息,其他的认证信息(比如部分应用可以获取的 refresh_token 信息)会统一存放到 userInfo 中 467 | */ 468 | @interface WBSDKAppRecommendResponse : WBBaseResponse 469 | @property (nonatomic,strong) WBAuthorizeResponse *authResponse; 470 | /** 471 | 用户ID 472 | */ 473 | @property (nonatomic, strong) NSString *userID; 474 | 475 | /** 476 | 认证口令 477 | */ 478 | @property (nonatomic, strong) NSString *accessToken; 479 | 480 | /** 481 | 认证过期时间 482 | */ 483 | @property (nonatomic, strong) NSDate *expirationDate; 484 | 485 | /** 486 | 当认证口令过期时用于换取认证口令的更新口令 487 | */ 488 | @property (nonatomic, strong) NSString *refreshToken; 489 | @end 490 | 491 | #pragma mark - Payment Request/Response 492 | 493 | /** 494 | 第三方应用发送消息至微博客户端程序的消息结构体 495 | */ 496 | @interface WBPaymentRequest : WBBaseRequest 497 | 498 | /** 499 | 发送给微博客户端的订单 500 | */ 501 | @property (nonatomic, strong) WBOrderObject *order; 502 | 503 | /** 504 | 返回一个 WBPaymentRequest 对象 505 | @param message 需要发送给微博客户端程序的消息对象 506 | @return 返回一个*自动释放的*WBSendMessageToWeiboRequest对象 507 | */ 508 | + (id)requestWithOrder:(WBOrderObject *)order; 509 | 510 | @end 511 | 512 | /** 513 | WBPaymentResponse 514 | */ 515 | @interface WBPaymentResponse : WBBaseResponse 516 | 517 | /** 518 | 支付返回状态码 519 | */ 520 | @property (nonatomic, strong) NSString *payStatusCode; 521 | 522 | /** 523 | 支付返回状态信息 524 | */ 525 | @property (nonatomic, strong) NSString *payStatusMessage; 526 | 527 | @end 528 | 529 | #pragma mark - MessageObject / ImageObject 530 | 531 | /** 532 | 微博客户端程序和第三方应用之间传递的消息结构 533 | 534 | 一个消息结构由三部分组成:文字、图片和多媒体数据。三部分内容中至少有一项不为空,图片和多媒体数据不能共存。 535 | */ 536 | @interface WBMessageObject : NSObject 537 | 538 | /** 539 | 消息的文本内容 540 | 541 | @warning 长度小于140个汉字 542 | */ 543 | @property (nonatomic, strong) NSString *text; 544 | 545 | /** 546 | 消息的图片内容 547 | 548 | @see WBImageObject 549 | */ 550 | @property (nonatomic, strong) WBImageObject *imageObject; 551 | 552 | /** 553 | 消息的多媒体内容 554 | 555 | @see WBBaseMediaObject 556 | */ 557 | @property (nonatomic, strong) WBBaseMediaObject *mediaObject; 558 | 559 | /** 560 | 返回一个 WBMessageObject 对象 561 | 562 | @return 返回一个*自动释放的*WBMessageObject对象 563 | */ 564 | + (id)message; 565 | 566 | @end 567 | 568 | /** 569 | 消息中包含的图片数据对象 570 | */ 571 | @interface WBImageObject : NSObject 572 | 573 | /** 574 | 图片真实数据内容 575 | 576 | @warning 大小不能超过10M 577 | */ 578 | @property (nonatomic, strong) NSData *imageData; 579 | 580 | /** 581 | 返回一个 WBImageObject 对象 582 | 583 | @return 返回一个*自动释放的*WBImageObject对象 584 | */ 585 | + (id)object; 586 | 587 | /** 588 | 返回一个 UIImage 对象 589 | 590 | @return 返回一个*自动释放的*UIImage对象 591 | */ 592 | - (UIImage *)image; 593 | 594 | @end 595 | 596 | #pragma mark - Message Media Objects 597 | 598 | /** 599 | 消息中包含的多媒体数据对象基类 600 | */ 601 | @interface WBBaseMediaObject : NSObject 602 | 603 | /** 604 | 对象唯一ID,用于唯一标识一个多媒体内容 605 | 606 | 当第三方应用分享多媒体内容到微博时,应该将此参数设置为被分享的内容在自己的系统中的唯一标识 607 | @warning 不能为空,长度小于255 608 | */ 609 | @property (nonatomic, strong) NSString *objectID; 610 | 611 | /** 612 | 多媒体内容标题 613 | @warning 不能为空且长度小于1k 614 | */ 615 | @property (nonatomic, strong) NSString *title; 616 | 617 | /** 618 | 多媒体内容描述 619 | @warning 长度小于1k 620 | */ 621 | @property (nonatomic, strong) NSString *description; 622 | 623 | /** 624 | 多媒体内容缩略图 625 | @warning 大小小于32k 626 | */ 627 | @property (nonatomic, strong) NSData *thumbnailData; 628 | 629 | /** 630 | 点击多媒体内容之后呼起第三方应用特定页面的scheme 631 | @warning 长度小于255 632 | */ 633 | @property (nonatomic, strong) NSString *scheme; 634 | 635 | /** 636 | 返回一个 WBBaseMediaObject 对象 637 | 638 | @return 返回一个*自动释放的*WBBaseMediaObject对象 639 | */ 640 | + (id)object; 641 | 642 | @end 643 | 644 | #pragma mark - Message Video Objects 645 | 646 | /** 647 | 消息中包含的视频数据对象 648 | */ 649 | @interface WBVideoObject : WBBaseMediaObject 650 | 651 | /** 652 | 视频网页的url 653 | 654 | @warning 不能为空且长度不能超过255 655 | */ 656 | @property (nonatomic, strong) NSString *videoUrl; 657 | 658 | /** 659 | 视频lowband网页的url 660 | 661 | @warning 长度不能超过255 662 | */ 663 | @property (nonatomic, strong) NSString *videoLowBandUrl; 664 | 665 | /** 666 | 视频数据流url 667 | 668 | @warning 长度不能超过255 669 | */ 670 | @property (nonatomic, strong) NSString *videoStreamUrl; 671 | 672 | /** 673 | 视频lowband数据流url 674 | 675 | @warning 长度不能超过255 676 | */ 677 | @property (nonatomic, strong) NSString *videoLowBandStreamUrl; 678 | 679 | @end 680 | 681 | #pragma mark - Message Music Objects 682 | 683 | /** 684 | 消息中包含的音乐数据对象 685 | */ 686 | @interface WBMusicObject : WBBaseMediaObject 687 | 688 | /** 689 | 音乐网页url地址 690 | 691 | @warning 不能为空且长度不能超过255 692 | */ 693 | @property (nonatomic, strong) NSString *musicUrl; 694 | 695 | /** 696 | 音乐lowband网页url地址 697 | 698 | @warning 长度不能超过255 699 | */ 700 | @property (nonatomic, strong) NSString *musicLowBandUrl; 701 | 702 | /** 703 | 音乐数据流url 704 | 705 | @warning 长度不能超过255 706 | */ 707 | @property (nonatomic, strong) NSString *musicStreamUrl; 708 | 709 | 710 | /** 711 | 音乐lowband数据流url 712 | 713 | @warning 长度不能超过255 714 | */ 715 | @property (nonatomic, strong) NSString *musicLowBandStreamUrl; 716 | 717 | @end 718 | 719 | #pragma mark - Message WebPage Objects 720 | 721 | /** 722 | 消息中包含的网页数据对象 723 | */ 724 | @interface WBWebpageObject : WBBaseMediaObject 725 | 726 | /** 727 | 网页的url地址 728 | 729 | @warning 不能为空且长度不能超过255 730 | */ 731 | @property (nonatomic, strong) NSString *webpageUrl; 732 | 733 | @end 734 | 735 | #pragma mark - OrderObject 736 | 737 | /** 738 | 微博客户端程序和第三方应用之间传递的订单结构 739 | */ 740 | @interface WBOrderObject : NSObject 741 | 742 | /** 743 | 订单编号 744 | */ 745 | @property (nonatomic, strong) NSString *orderString; 746 | 747 | 748 | /** 749 | 返回一个 WBOrderObject 对象 750 | 751 | @return 返回一个*自动释放的*WBOrderObject对象 752 | */ 753 | + (id)order; 754 | 755 | @end -------------------------------------------------------------------------------- /ios/libWeiboSDK/WeiboUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // WeiboUser.h 3 | // WeiboSDK 4 | // 5 | // Created by DannionQiu on 14-9-23. 6 | // Copyright (c) 2014年 SINA iOS Team. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /*@ 12 | You can get the latest WeiboUser field description on http://open.weibo.com/wiki/2/friendships/friends/en . 13 | */ 14 | @interface WeiboUser : NSObject 15 | 16 | - (instancetype)initWithDictionary:(NSDictionary*)paraDict; 17 | + (instancetype)userWithDictionary:(NSDictionary*)paraDict; 18 | 19 | // Validate the dictionary to be converted. 20 | + (BOOL)isValidForDictionary:(NSDictionary *)dict; 21 | 22 | - (BOOL)updateWithDictionary:(NSDictionary*)paraDict; 23 | 24 | 25 | @property(readwrite, strong, nonatomic) NSString* userID; 26 | @property(readwrite, strong, nonatomic) NSString* userClass; 27 | @property(readwrite, strong, nonatomic) NSString* screenName; 28 | @property(readwrite, strong, nonatomic) NSString* name; 29 | @property(readwrite, strong, nonatomic) NSString* province; 30 | @property(readwrite, strong, nonatomic) NSString* city; 31 | @property(readwrite, strong, nonatomic) NSString* location; 32 | @property(readwrite, strong, nonatomic) NSString* userDescription; 33 | @property(readwrite, strong, nonatomic) NSString* url; 34 | @property(readwrite, strong, nonatomic) NSString* profileImageUrl; 35 | @property(readwrite, strong, nonatomic) NSString* coverImageUrl; 36 | @property(readwrite, strong, nonatomic) NSString* coverImageForPhoneUrl; 37 | @property(readwrite, strong, nonatomic) NSString* profileUrl; 38 | @property(readwrite, strong, nonatomic) NSString* userDomain; 39 | @property(readwrite, strong, nonatomic) NSString* weihao; 40 | @property(readwrite, strong, nonatomic) NSString* gender; 41 | @property(readwrite, strong, nonatomic) NSString* followersCount; 42 | @property(readwrite, strong, nonatomic) NSString* friendsCount; 43 | @property(readwrite, strong, nonatomic) NSString* pageFriendsCount; 44 | @property(readwrite, strong, nonatomic) NSString* statusesCount; 45 | @property(readwrite, strong, nonatomic) NSString* favouritesCount; 46 | @property(readwrite, strong, nonatomic) NSString* createdTime; 47 | @property(readwrite, assign, nonatomic) BOOL isFollowingMe; 48 | @property(readwrite, assign, nonatomic) BOOL isFollowingByMe; 49 | @property(readwrite, assign, nonatomic) BOOL isAllowAllActMsg; 50 | @property(readwrite, assign, nonatomic) BOOL isAllowAllComment; 51 | @property(readwrite, assign, nonatomic) BOOL isGeoEnabled; 52 | @property(readwrite, assign, nonatomic) BOOL isVerified; 53 | @property(readwrite, strong, nonatomic) NSString* verifiedType; 54 | @property(readwrite, strong, nonatomic) NSString* remark; 55 | @property(readwrite, strong, nonatomic) NSString* statusID; 56 | @property(readwrite, strong, nonatomic) NSString* ptype; 57 | @property(readwrite, strong, nonatomic) NSString* avatarLargeUrl; 58 | @property(readwrite, strong, nonatomic) NSString* avatarHDUrl; 59 | @property(readwrite, strong, nonatomic) NSString* verifiedReason; 60 | @property(readwrite, strong, nonatomic) NSString* verifiedTrade; 61 | @property(readwrite, strong, nonatomic) NSString* verifiedReasonUrl; 62 | @property(readwrite, strong, nonatomic) NSString* verifiedSource; 63 | @property(readwrite, strong, nonatomic) NSString* verifiedSourceUrl; 64 | @property(readwrite, strong, nonatomic) NSString* verifiedState; 65 | @property(readwrite, strong, nonatomic) NSString* verifiedLevel; 66 | @property(readwrite, strong, nonatomic) NSString* onlineStatus; 67 | @property(readwrite, strong, nonatomic) NSString* biFollowersCount; 68 | @property(readwrite, strong, nonatomic) NSString* language; 69 | @property(readwrite, strong, nonatomic) NSString* star; 70 | @property(readwrite, strong, nonatomic) NSString* mbtype; 71 | @property(readwrite, strong, nonatomic) NSString* mbrank; 72 | @property(readwrite, strong, nonatomic) NSString* block_word; 73 | @property(readwrite, strong, nonatomic) NSString* block_app; 74 | @property(readwrite, strong, nonatomic) NSString* credit_score; 75 | @property(readwrite, strong, nonatomic) NSDictionary* originParaDict; 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /ios/libWeiboSDK/libWeiboSDK.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reactnativecn/react-native-weibo/652f0071473a5e76d71bbdbb8e6f3eb3dff18f76/ios/libWeiboSDK/libWeiboSDK.a -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-weibo", 3 | "version": "3.0.4", 4 | "description": "新浪微博登录、分享模块", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/reactnativecn/react-native-weibo.git" 12 | }, 13 | "keywords": [ 14 | "react-native", 15 | "ios", 16 | "android", 17 | "weibo", 18 | "sina", 19 | "share", 20 | "login" 21 | ], 22 | "author": "lvbingru", 23 | "license": "ISC", 24 | "bugs": { 25 | "url": "https://github.com/reactnativecn/react-native-weibo/issues" 26 | }, 27 | "homepage": "https://github.com/reactnativecn/react-native-weibo#readme", 28 | "dependencies": { 29 | "es6-promisify": "^3.0.0" 30 | } 31 | } 32 | --------------------------------------------------------------------------------