Account/update profile/en
目录 |
account/update_profile
Update profile of the authenticating user.
URL
http://api.t.sina.com.cn/account/update_profile.(json%7Cxml)
Supported Formats
XML/JSON
HTTP Request Method
POST
Requires Authentication
true
See the Authorization Mechanism Statement for authorization details
Requests Count Limitation
true
See the Interface Access Rights Statement for the Request Count Limitaiton details.
Request Parameters
Requires | Type and Range | Description | |
---|---|---|---|
source | true | string | AppKey for the application to identify it. ( This parameter is not needed when using OAuth) |
You Must use at least one of the parameters below, multi-parameters are also accepted.
| |||
name | false | string | nick, limited by 20 Chinese characters. |
gender | false | string | Gender, m means male, f means female. |
province | false | int | Province code, see Province and city code table |
city | false | int | City code, 1000 means undefined city. see Province and city code table |
description | false | string | Personal description. Limited by 160 Chinese characters. |
Notes
- After API is called successfully, only the items in parameters are updated, others are not changed.
- For example, if name and gender have been set, only name and gender will be updated. User’s province, city and personal description will not be changed.
Example Request
- XML
- curl -u "username:password" -d "gender=m&name=openapi" "http://api.t.sina.com.cn/account/update_profile.xml?source=appkey"
- JSON
- curl -u "username:password" -d "gender=m&name=openapi" "http://api.t.sina.com.cn/account/update_profile.json?source=appkey"
Response
XML Example
<?xml version="1.0" encoding="UTF-8"?> <user> <id>11075</id> <screen_name>openapi</screen_name> <name>openapi</name> <province>广东</province> <city>广州</city> <location>广东 广州</location> <description></description> <url></url> <profile_image_url>http://portrait.sinaimg.cn/11075/50#.jpg</profile_image_url> <domain></domain> <gender></gender> <followers_count>0</followers_count> <friends_count>0</friends_count> <statuses_count>0</statuses_count> <favourites_count>0</favourites_count> <created_at>Thu Jan 01 08:00:00 +0800 1970</created_at> <following>false</following> <verified>false</verified> <geo_enabled>false</geo_enabled> <status> <created_at>Fri Dec 25 17:57:27 +0800 2009</created_at> <id>19093</id> <text>测试</text> <source> <a id="0" href="http://t.sina.com.cn">Web</a> </source> <favorited>false</favorited> <truncated>false</truncated> <geo/> <in_reply_to_status_id></in_reply_to_status_id> <in_reply_to_user_id></in_reply_to_user_id> <in_reply_to_screen_name></in_reply_to_screen_name> </status> </user>
JSON Example
{ "id":11075, "screen_name":"openapi", "name":"openapi", "province":"0", "city":"0", "location":"", "description":"", "url":"", "profile_image_url":"http://tp4.sinaimg.cn/11075/50/0", "domain":"11075", "followers_count":28, "friends_count":50, "statuses_count":29, "favourites_count":0, "created_at":"Thu Jan 01 08:00:00 +0800 1970", "following":false, "geo_enabled":false, "verified":true, "status": {"created_at":"Thu Jan 07 17:36:07 +0800 2010", "id":142309, "text":"测试", "source":"<a id=\"0\" href=\"http://t.sina.com.cn/\" rel=\"nofollow\">Web</a>", "favorited":false, "truncated":false, "in_reply_to_status_id":"", "in_reply_to_user_id":"", "in_reply_to_screen_name":"", "geo":null} }
Others
Java Example
Please download Java SDK from . Weibo SDK Development Kit Dowload Site
Sample Code:
package weibo4j.examples; import weibo4j.User; import weibo4j.Weibo; public class OAuthUpdateProfile { /** * Usage: java -DWeibo4j.oauth.consumerKey=[consumer key] * -DWeibo4j.oauth.consumerSecret=[consumer secret] * Weibo4j.examples.OAuthUpdateProfile [accessToken] [accessSecret] * [imageFilePath] * * @param args * message */ public static void main(String[] args) { try { if (args.length < 3) { System.out.println( "Usage: java weibo4j.examples.OAuthUpdateProfile token tokenSecret filePath"); System.exit( -1); } System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY); System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET); Weibo weibo = new Weibo(); /* * 此处需要填写AccessToken的key和Secret,可以从OAuthUpdate的执行结果中拷贝过来 */ weibo.setToken(args[0], args[1]); try { //args[2]:昵称;args[3]:email;args[4]:头像地址;args[5]:地区;args[6]:描述 User user = weibo.updateProfile(args[2],args[3],args[4],args[5],args[6]); System.out.println(user.toString()); } catch (Exception e1) { e1.printStackTrace(); } } catch (Exception ioe) { System.out.println("Failed to read the system input."); } } }
PHP Example
Please download PHP SDK with OAUTH supported from Weibo SDK Development Kit Dowload Site
.
Sample Code:
//account/update_profile $c = new WeiboClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret'] ); //name you want to change to $name = 'name'; //gender you want to change to $gender = 'f'; $param = array(); $param['name'] = $name; $param['gender']= $gender; $msg = $c->oauth->post('http://api.t.sina.com.cn/account/update_profile.json',$param); if ($msg === false || $msg === null){ echo "Error occured"; return false; } if (isset($msg['error_code']) && isset($msg['error'])){ echo ('Error_code: '.$msg['error_code'].'; Error: '.$msg['error'] ); return false; } if (isset($msg['name'])){ echo($msg['name']); }