Record of research results on calling facebook and twitter to publish messages

Source: Internet
Author: User

Recently, a mobile project needs to add two features to the project. They send message buttons on twitter and facebook. Customers do not want to create their own interfaces and want to directly call pages on their respective websites to send messages. These two websites are very popular in foreign countries, but they cannot be accessed in China, and they have never been used. So I started to query the information.

1. Twitter

Sending messages on twitter is actually very simple. In many places, the twitter button production function is provided, and access is fully supported by the get method. That is to say, you can directly enter a url to open the corresponding twitter page and pass in the desired information. Comparing the reference of twitter by a foreign website and the descriptions of the button provided on the official website, we quickly found such an address, for example:

Http://twitter.com/intent/tweet? Status = I % 20 think % 20is % 20 @ zsz417 http://baidu.com

This address is used to modify the user's status, but twitter seems to have a status. All the information is expressed simply by status. You see, there are content, URLs, and @ someone. Writing them directly is complete. Of course, because twitter has a limit of 140 characters (can 140 characters in foreign countries express adequate meaning), if the url is relatively long, it is best to use the short URL service to shorten the URL. After several simple tests, I handed the link to my colleagues in the mobile group.

However, the mobile Group will soon find it, saying that every time twitter is sent, it is quite troublesome. After tracking, we found that mobile will automatically redirect to mobile.twitter.com to access twitter, And the cookie is only valid for mobile.twitter.com (of course it is also valid for the current connection ), this website is a web version and requires cookieon http://www.twitter.com. (This twitter is too unauthentic. How can this happen ?)

Due to poor English, it is also very labor-intensive to check the information, and the information on the baidu is almost ineffective. However, when google searches for sensitive words, it is often blocked. I have meed a mi, and the man is in tianchao, just imagine it. Guess it. Change the access path:

Http://mobile.twitter.com/intent/tweet? Status = I % 20 think % 20is % 20 @ zsz417 http://baidu.com

After entering the address, I jumped to the @ intent user page. I went there and encrypted the connection. It seems that this guess is not powerful.

While searching and guessing, I found another method:

Http://twitter.com /? Status = content

So, does it have the corresponding mobile version:

Https://mobile.twitter.com /? Status =

The encrypted connection is automatically redirected (I changed the agent to the iphone ). Isn't it better to directly access this on mobile? I quickly handed it to my colleagues in the mobile Group for testing. OK, I passed.

 

Note: because twitter has a limit on the number of characters (140 characters), it is best to consider using the short URL service for URLs. I heard that twitter once (?) By default, bit. ly is used. Therefore, an account is registered, a key is applied for, and an experiment is conducted. It is very helpful. Here we record it:

Open the following URL directly using get. The returned data is the URL.

Http://api.bitly.com/v3/shorten? Login = bitlyapidemo & apiKey = R_0da49e0a9118ff35f52f629d2d71bf07 & longUrl = http % 3A % 2F % 2Fbetaworks.com % 2F & format = txt

The parameter meanings are as follows:

    1. Login is the user name you registered on the bit. ly website;
    2. ApiKey is actually the key assigned to you by the system, which must correspond to login;
    3. LongUrl is a long address that requires short processing;
    4. Format, which can be txt, json, or xml.

2. Facebook

There are still some facebook materials that are suitable for us. There is a link on the materials (note that this usage has expired ):

Http://www.facebook.com/sharer/sharer.php? U = http://www.sina.com.cn & t = this is sina

Here, the u parameter is a link and t is the title, which means you can share a webpage and define the title. This is also true for many web pages in. However, after testing, facebook optimized the sharer. It automatically captured the title of the webpage and the title of the homepage, and even some of the images and descriptions, there is also a box for user input. That is to say, only the format of the u parameter is correct. The t parameter is no longer valid. After several tests, the customer's requirements cannot be fulfilled, so they have to find other resources. (I have not found this sharer usage in the facebook api document ).

In the dialog box project of the facebook api document, we found this usage:

Http://www.facebook.com/dialog/feed? App_id = 123050457758183 & redirect_uri = http://www.facebook.com & message = I % 27 m % 20not % 20 ignoring % 20you. % 20I % 27 m % 20 just % 20 waiting % 20for % 20you % 20to % 20 talk % 20to % 20me % 20first. % 20 http://baidu.com

Where:

    1. App_id is required. It can be 123020457758183. This value is the id of a facebook app called Cool Social App, I think this is a public app provided by facebook (it can also be another app value, and the icon and name of the corresponding app will be displayed );
    2. Redirect_uri is also a required parameter. The page on which the user returns the graffiti wall message. Our app does not have its own independent page, so return to facebook;
    3. Message indicates that you want to include text in the input box of the graffiti wall. There is no limit on the quantity. Of course, this is not a required item.

Other optional items include:

    1. Link;
    2. Picture: displays an image;
    3. Name: the title of the link. The first line is displayed under the graffiti wall input box. The font is bold;
    4. Caption, description/abstract, which is displayed in one line below the title;
    5. Description, which is detailed and displayed below the abstract.

Let's keep a record first. I don't know which day facebook wants to modify its api,/dizzy.

Note:

    1. Facebook has a mobile page, http://m.facebook.com/dialog/feed? App_id = 123050457758183 & redirect_uri = http://m.facebook.com & message = I % 27 m % 20not % 20 ignoring % 20you. % 20I % 27 m % 20 just % 20 waiting % 20for % 20you % 20to % 20 talk % 20to % 20me % 20first. % 20 http://baidu.com but unstable, and display abnormal in wp7 now IE7 (show normal in iphone ). for general purposes, you may wish to call something starting with www.
    2. Pay attention to turning over the wall. In addition, these APIs are available on the official website. Please make good use of English.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.