This article is about reposting an article about the solution to the 20007 error caused by the Sina Weibo PHP version SDK. Friends who encounter such problems can refer to it.
Sina Weibo has an advanced interface ‘statuses/upload_url_text’ (requires additional application in open.weibo.com).
By passing an image URL address and text content, you can post a picture and text Weibo
The functions corresponding to the php version of SDK are as follows:
代码如下 |
复制代码 |
? /**
* 指定一个图片URL地址抓取后上传并同时发布一条新微博
*
* 对应API:{@link http://open.weibo.com/wiki/2/statuses/upload_url_text statuses/upload_url_text}
*
* @param string $status 要发布的微博文本内容,内容不超过140个汉字。
* @param string $url 图片的URL地址,必须以http开头。
* @return array
*/
function upload_url_text( $status, $url )
{
$params = array();
$params['status'] = $status;
$params['url'] = $url;
return $this->oauth->post( 'statuses/upload', $params, true );
}
|
There is an obvious error in calling the api: $this->oauth->post( 'statuses/upload', $params, true );
(On the one hand, it should request: statuses/upload_url_text, on the other hand, the third parameter is wrong)
As a result: 20007 error (20007: does multipart has image?)
It will be ok if you change it to this:
The code is as follows
代码如下 |
复制代码 |
? /**
* 指定一个图片URL地址抓取后上传并同时发布一条新微博
*
* 对应API:{@link http://open.weibo.com/wiki/2/statuses/upload_url_text statuses/upload_url_text}
*
* @param string $status 要发布的微博文本内容,内容不超过140个汉字。
* @param string $url 图片的URL地址,必须以http开头。
* @return array
*/
function upload_url_text( $status, $url )
{
$params = array();
$params['status'] = $status;
$params['url'] = $url;
return $this->oauth->post( 'statuses/upload_url_text', $params, false);
}
|
|
Copy code |
|
? /**
* Specify an image URL address to capture, upload and publish a new Weibo at the same time
*
* Corresponding API: {@link http://open.weibo.com/wiki/2/statuses/upload_url_text statuses/upload_url_text}
*
* @param string $status Weibo text content to be published, the content should not exceed 140 Chinese characters.
* @param string $url The URL address of the image must start with http.
* @return array
*/
function upload_url_text( $status, $url )
{
$params = array();
$params['status'] = $status;
$params['url'] = $url;
Return $this->oauth->post( 'statuses/upload_url_text', $params, false);
}
http://www.bkjia.com/PHPjc/632141.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/632141.htmlThis article is about the solution to the 20007 error caused by the Sina Weibo PHP version SDK. I encountered this Friends who have similar problems can refer to it. Sina Weibo has an advanced interface statuses/upload_url_text (...