Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpException with uploadArticle API #544

Closed
djade007 opened this issue Dec 13, 2016 · 13 comments
Closed

HttpException with uploadArticle API #544

djade007 opened this issue Dec 13, 2016 · 13 comments

Comments

@djade007
Copy link

djade007 commented Dec 13, 2016

我用的环境

PHP 版本:7.0
overtrue/wechat 版本:3.1

问题及现象

I'm unable to use Material::uploadArticle(). I keep getting empty content error Exception.

##wechat logs
media_id gotten from Material::uploadThumb();

easywechat.DEBUG: Client Request: {"url":"https://api.weixin.qq.com/cgi-bin/material/add_news","method":"POST","options":{"timeout":5,"body":"{"articles":[{"thumb_media_id":"media_id","author":"TEST","digest":"This is the summary","show_cover_pic":1,"content":"This is a test content","content_source_url":"http://example.com"}]}","headers":{"content-type":"application/json"}}} []

[2016-12-13 22:52:46] easywechat.DEBUG: API response decoded: {"contents":{"errcode":44004,"errmsg":"empty content hint: [tlL0965e541]"}} []

@overtrue
Copy link
Collaborator

plz post your code.

@djade007
Copy link
Author

djade007 commented Dec 14, 2016

$m = app('wechat')->material->uploadThumb($path);

$article = new \EasyWeChat\Message\Article([
'thumb_media_id' => $m->media_id,
'author' => 'TEST',
'tittle' => 'Test Tittle',
'content' => "This is a test content",
'digest' => 'description',
'content_source_url' => 'http://example.com',
'show_cover_pic' => 1
]);

$r = app('wechat')->material->uploadArticle($articles);

@overtrue
Copy link
Collaborator

'thumb_media_id' => $m->media_id

media_id gotten from Material::uploadThumb(); ???

get media id:

$result = $material->uploadThumb("/path/to/your/thumb.jpg"); 
$mediaId = $result->media_id;
// {
//    "media_id":MEDIA_ID,
// }

and upload article:

use EasyWeChat\Message\Article;
// 上传单篇图文
$article = new Article([
    'title' => 'xxx',
    'thumb_media_id' => $mediaId,
    //...
  ]);
$material->uploadArticle($article);

@djade007
Copy link
Author

Yes media Id gotten from Material::uploadThumb().

$m = app('wechat')->material->uploadThumb($path);

@overtrue
Copy link
Collaborator

@djade007 it seems like that you missing the title key of Article , plz take a check.

@djade007
Copy link
Author

The title is there.

@overtrue
Copy link
Collaborator

@djade007 I'm sorry, I've tried my best.

@djade007
Copy link
Author

@overtrue, please can you try to test the Material::uploadArticle() from your end?

@overtrue
Copy link
Collaborator

yes, I've tried.

@djade007
Copy link
Author

You are right, there was a typo in the title, I was using 'tittle'.

@overtrue
Copy link
Collaborator

@djade007 💔💔💔💔💔💔💔

@djade007
Copy link
Author

I would blame the wechat api, the error message wasn't helpful. I kept thinking it was the content field that was missing.

Thanks for taking your time to help.

@overtrue
Copy link
Collaborator

@djade007 you are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants