[英]Twitter API - Update Profile
Im looking at the Twitter API: http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-account%C2%A0update_profile 我正在查看Twitter API: http : //apiwiki.twitter.com/Twitter-REST-API-Method%3A-account%C2%A0update_profile
I want to update my profile via PHP. 我想通过PHP更新我的个人资料。
Specifically my location: San Francisco, CA 特别是我的位置:加利福尼亚州旧金山
Im not looking for anything fancy, just a way of calling the XML, checking its contents, then writing in a new value if appropriate. 我不会寻找任何花哨的东西,只是一种调用XML,检查其内容,然后在适当时写入新值的方式。
Can anyone point me in the right direction? 谁能指出我正确的方向?
public function updateProfile($name = null, $email = null, $url = null, $location = null, $description = null)
{
// validate parameters
if($name === null && $email === null && $url === null && $location === null && $description === null) throw new TwitterException('Specify at least one parameter.');
if($name !== null && strlen($name) > 40) throw new TwitterException('Maximum 40 characters allowed for name.');
if($email !== null && strlen($email) > 40) throw new TwitterException('Maximum 40 characters allowed for email.');
if($url !== null && strlen($url) > 100) throw new TwitterException('Maximum 100 characters allowed for url.');
if($location !== null && strlen($location) > 30) throw new TwitterException('Maximum 30 characters allowed for location.');
if($description !== null && strlen($description) > 160) throw new TwitterException('Maximum 160 characters allowed for description.');
// build parameters
if($name !== null) $aParameters['name'] = (string) $name;
if($email !== null) $aParameters['email'] = (string) $email;
if($url !== null) $aParameters['url'] = (string) $url;
if($location !== null) $aParameters['location'] = (string) $location;
if($description !== null) $aParameters['description'] = (string) $description;
// make the call
$response = $this->doCall('account/update_profile.xml', $aParameters, true);
// convert into xml-object
$xml = @simplexml_load_string($response);
// validate
if($xml == false) throw new TwitterException('invalid body');
// return
return (array) $this->userXMLToArray($xml, true);
}
curl -u user:password -d "location=San Francisco, CA" http://twitter.com/account/update_profile.xml
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.