Custom Weibo tail (source code + resolution), source code
Preface:
Since Wang Sicong published the microblog with the iPhone 6 tail, more and more people are following suit and changing the tail to the iPhone 6. However, Sina has made the original solution harmonious in a short time. The original method was very simple, that is, manually set the app_url (that is, the key corresponding to each model mobile phone) through the web page publishing window, and publish Weibo here to modify the Weibo tail.
For example, the following is the code for iPhone 5s !!
Http://widget.weibo.com/dialog/PublishWeb.php? Mid = & default_text = & language = zh_cn & app_src = http://widget.weibo.com/dialog/PublishWeb.php? Mid = & default_text = & language = zh_cn & app_src = 3G5oUM & tag = & title = % E5 % 8F % 91% E5 % B8 % 83% E5 % BE % AE % E5 % 8D % 9A & button = publish & re
As I have said before, this method has been harmonized. Now we use this method and all it comes out are"From the release window ".
But there is always a solution. It took me two days to write this iOS-based APP to customize and modify the Weibo tail.
:
If you want to continue learning the implementation method. Welcome to continue reading. We should have some gains. We recommend that you download the source code first. (The source code is based on iOS. But the implementation methods, corresponding interfaces and data are all common)
Of course, this interface is Sina. So no one knows when it will be harmonious. In short, it's right now.
Source code download link: https://github.com/colin1994/weiboTail.git
The content includes:
- Weibo INTERFACE ANALYSIS
- UITableView + UISearchBar
- UITableView grading menu
- Youmi advertisement embedding
I. Weibo Interface Analysis: We observe Weibo's tail and can get two categories:
Mobile Phone Model and Application name. There is no custom yellow brick privilege like QQ space. In addition, its blue link is valid. Mobile phone model. When we send Weibo posts, if it is a mobile phone, it will automatically display the corresponding tail Based on the hardware information of the device. Every device, Sina will allocate
App_urlThis is unique, including the newly released iPhone 6 and its corresponding app_url. The Application name is the name of each application registered on the Weibo development platform. Each application has an independent sharing link. If you share the application, the corresponding tail will be taken. The corresponding appKey is used to differentiate applications. Now, the analysis is complete. Next, let's take a look at what we need to do to implement this function.
1. Obtain the app_url of each mobile phone model. I have collected this information. Of course, not all. It is just a list of commonly used. Of course, there are several iPhone types that are essential for installation. It can be used directly. The file format is. plist. iOS can be opened directly, but on other systems, you need to read it by yourself. Its data format is XML. Reading should be fine. As for how to obtain it, the method is as follows: 1. Baidu collects. 2. Right-click Weibo and view the link.
2. Call the mobile phone model. The previous method is to call the release window, but this is already harmonious. Similarly, I tried to call the "topic window" and found that this function is still available and can be customized normally. In addition, we can customize a topic. In this way, Weibo's WeChat tail application will be displayed here, which is convenient. The calling method is as follows:
WebView. webStr = [NSString stringWithFormat: @ "http://widget.weibo.com/topics/topic_vote_base.php? Tag = from Weibo tail & isshowright = 0 & language = zh_cn & dup = 1 & antispam = 1 & isOutTopicSearch = 2 & border = 0 & version = base & footbar = 0 & app_src = % @", appKey];
Here, webStr is an NSStirng string used to save the corresponding URL. AppKey is obtained from plist Based on the selected mobile phone model. After webStr is passed in, the call is displayed.
webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 64, 320, Screen_height-64)]; request =[NSURLRequest requestWithURL:[NSURL URLWithString:[webStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; [webView setDelegate:self]; [self.view addSubview: webView]; [webView loadRequest:request];
In this way, Weibo can be published on a webpage. Then it shows your favorite little tail. It's easy.
3. Application appKey acquisition and use
Similarly, I have collected more than 100 application names, which are quite interesting. Method: Go to Weibo app square ----> select an app -----> display page source code ------> Search for appKey. .
Call method:
webView.webStr = [NSString stringWithFormat:@"http://v.t.sina.com.cn/share/share.php?appkey=%@&;content=utf8", appKey];
II. UITableView + UISearchBar
// Add the list myTableView = [[UITableView alloc] initWithFrame: CGRectMake (0,104,320, Screen_height-154)]; myTableView. delegate = self; myTableView. dataSource = self; // the background color myTableView. backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @ "eyeBackground.jpg"]; [self. view addSubview: myTableView]; // initialize the search list bar filteredArr = [NSMutableArray alloc] init]; searchBarReagion = [[UISearchBar alloc] initWithFrame: CGRectMake (,)]; searchBarReagion. placeholder = @ "Search"; searchBarReagion. delegate = self; [self. view addSubview: searchBarReagion];
#pragma mark#pragma mark SearchBar Delegate- (void) searchBarTextDidBeginEditing: (UISearchBar*) searchBar{ [searchBarReagion setShowsCancelButton: YES animated: YES];}- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{ isSearchActiveDM = TRUE; [filteredArr removeAllObjects]; for (int i=0; i<resultArr.count; i++) { NSDictionary *countryDictinary = [resultArr objectAtIndex:i]; NSRange result=[[countryDictinary objectForKey:@"appName"] rangeOfString:searchText options:NSCaseInsensitiveSearch]; if(result.length>0) { [filteredArr addObject:countryDictinary]; } } [myTableView reloadData];}- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{ [searchBarReagion resignFirstResponder]; [searchBarReagion setShowsCancelButton: NO animated: YES];}- (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar{ isSearchActiveDM = FALSE; searchBarReagion.text = @""; [searchBarReagion setShowsCancelButton: NO animated: YES]; [searchBarReagion resignFirstResponder]; [myTableView reloadData];}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if (isSearchActiveDM) { return [filteredArr count]; } return [resultArr count];}
The code above shows that UITableView and UISearchBar are not directly linked. All implement their respective methods. However, after entering the content in the search box, mark it as isSearchActiveDM. Then, in each method that UITableView needs to implement, different data is displayed by judging whether it is in isSearchActiveDM. To achieve the dynamic search effect.
3. UITableView grading menu here, I found a good demo in code4app. I have integrated it into the application. The source file is in the NavigationStackResource folder. Call method:
//Initialize the controller data NSString* plistPath = [[NSBundle mainBundle] pathForResource: @"NavStackControllerData" ofType: @"plist"]; // Build the array from the plist self.jsonDictionary = [[NSDictionary alloc] initWithContentsOfFile:plistPath]; //customizing.. [self setHeaderLabelFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:20.0f]]; [self setHeaderLabelColor:[UIColor blackColor]]; [self setHeaderBackGroundColor:[UIColor whiteColor]]; [self setSelectedHeaderLabelFont:[UIFont fontWithName:@"HelveticaNeue-Bold" size:20.0f]]; [self setSelectedHeaderLabelColor:[UIColor blackColor]]; [self setSelectedHeaderBackGroundColor:[UIColor whiteColor]]; [self setHeaderSeparatorColor:[UIColor lightGrayColor]];
Select the response methods for each cell:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ appKey = [[[[self.jsonDictionary objectForKey:self.clickedCountryName]objectForKey:@"subheadingArr"]objectAtIndex:indexPath.row]objectForKey:@"subheadingKey"]; appName = [[[[self.jsonDictionary objectForKey:self.clickedCountryName]objectForKey:@"subheadingArr"]objectAtIndex:indexPath.row]objectForKey:@"subheadingName"]; [self performSegueWithIdentifier:@"phonePushToWeb" sender:self];}
4. Implantation of Rice advertisements
1. register the application and apply for an ID
1) Please log onto the http://www.youmi.net/register to register a developer account
2) ClickCreate an applicationCreate a new application.
3) viewApplication DetailsTo obtain the release ID and application key, which will be used in subsequent initialization. (Note: An appid can only correspond to one bundle id. If you have special requirements, contact customer service.)
2. Download The YouMiSDK iOS package
The compressed package you downloaded contains the following files:
DocThe doc.html in the folder is a Chinese tutorial, and doc_en.html is an English tutorial.
LibThe folder is the folder to be added to your project. It contains the libYouMi. a static file and header file.
SamplesProgram example of the folder YouMiSDK.
3. Import the header file and static library file to the project.
The header file required by the integral wall is
The static library file is
4. Add the built-in Frameworks for the project
- Security. framework
- SystemConfiguration. framework
- CFNetwork. framework
- QuartzCore. framework
- Libsqlite3.dylib
- Change StoreKit. framework to Optional.
5. initialize YouMiSDK in the AppDelegate. m file.
- 1) Add the following statement to the AppDelegate. m file:
#import "YouMiConfig.h"
- 2) automatically generated in AppDelegate. m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Add the following code to the Function
[YouMiConfig setUserID: id_you_define]; // [Optional] For example, a developer's application has the logon function, you can use the user account after logon to replace the identifier provided by meters for each machine (the unique identifier generated by meters for each device ). [YouMiConfig setUseInAppStore: YES]; // [Optional] enable the built-in appStore. For details, refer to the FAQs of YouMiSDK [YouMiConfig launchWithAppID: @ "[Your AppID]" appSecret: @ "[Your AppSecret]"];
Note: Replace the Your AppID and Your AppSecret with YourappidAndappSecret
The code snippets in this document are described in detail in the corresponding SDK header files. If you have any questions about the code in this document, please refer to the header files.
- 3) set full-screen UIWindow for displaying full-screen advertisements (such as integral walls) (optional, recommended)
For apps written using UIKit, you can set it after [self. window makeKeyAndVisible] In application: didfinishlaunchingwitexceptions:
[Self. window makeKeyAndVisible]; // sets the window [YouMiConfig setFullScreenWindow: self. window] for displaying full-screen advertisements;
Here, my demo only uses simple ad strips. For other integral walls and other things, you can refer to the document as needed.
Call Ad strips to create and add ad strips where ad strips are needed
// Create ad bar adView = [[YouMiView alloc] initWithContentSizeIdentifier: YouMiBannerContentSizeIdentifier320x50 delegate: nil]; // you can set the delegate [Optional] adView. delegate = self; // set the attributes of a text ad [Optional] adView. indicatetranspoliccy = YES; adView. indicateRounded = NO; // Add the corresponding keyword [Optional] [adView addKeyword: @ ""]; // start requesting the advertisement [adView start]; // Add an advertisement bar to a specific view [for example] [self. view addSubview: adView];
Sina Weibo tail display problems
Me too. I have been improving it. Wait.
Sina Weibo's little tail
The Weibo client has long canceled its tail and wants its tail to go to some forums, such as fan Feng and the next modified Weibo client, which will carry its tail directly!