Drupal 7 module
This module uses V2 of the weibo API and allows you to choose content types that will autopost to your assigned Weibo Profile page.

From wikipedia:
Sina Weibo is a Chinese microblogging (weibo) website. Akin to a hybrid of Twitter and Facebook, it is one of the most popular sites in China, in use by well over 30% of Internet users.

Current Features;
- Choose Content Types for autopost
- Include Images for post (max 5mb set by API)
- Post will be in the format of 【title】truncated summary (shortened link to node) (max 140chars total)
- latest 20 Weibo post is listed in admin/reports/weibo_mangement.

http://open.weibo.com/wiki/API%E6%96%87%E6%A1%A3_V2/en

Installation

Download http://code.google.com/p/sinatopenapi/source/browse/trunk/SinaOpenApi.ph...
Save as SinaOpenApi.php and put into weibo_post module folder.

Project Page: http://drupal.org/sandbox/xenyo/1447074
Git Clone: git clone --branch 7.x-1.x http://git.drupal.org/sandbox/xenyo/1447074.git weibo_autopost
Drupal Version: 7

Reviews of other projects:

Comments

maxtorete’s picture

Status: Needs review » Needs work
StatusFileSize
new16.25 KB

Some initial comments with a superficial review:

You should change the URI on the first post to the public URI: git clone http://git.drupal.org/sandbox/xenyo/1447074.git weibo_autopost

Manual review

You must delete all variables set by your module on hook_uninstall.
You are using 'und' variables, that are used only if the language is undetermined, you can use the function I post below instead to get the values of current language:

$weibo_body = field_get_items('node', $form_state, 'summary');

Automate review

You can find an automate code review from Drupal Code Sniffer here. I paste here the resume and attach the errors log.

It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Review of the master branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Get a review bonus and we will come back to your application sooner.

Greets!

maxtorete’s picture

Ummmmm, I think that field_get_items would not be used on a form context, so maybe you must look for other solution there.

xenyo’s picture

Issue summary: View changes

change git link

xenyo’s picture

Assigned: Unassigned » xenyo
Status: Needs work » Needs review

module recommited, please review again .

xenyo’s picture

Assigned: xenyo » Unassigned

Unassign.

xenyo’s picture

It may be a bit hard for you guys to review as Weibo is Chinese only and an account is needed. Anything we can do to make review easier?

patrickd’s picture

We had those cases several time, a good solution would be to provide us the access data for a testaccount, if possible.

xenyo’s picture

Thanks Patrick,

Made a test site and installed the module at here . (AUTO-LOGIN LINK)

You can add an article and THE SUMMARY of the post will be posted on a Weibo profile page we have set up at http://weibo.com/2615329401/profile. The module is set to post the title, summary and image with link back to the post. The summary is used as often the post needs to be tweaked to make it viable for the 140character limit.

Important Note: You need to log into Weibo to see profile, can use the test acct: wingkai738@yahoo.com.hk / yoshiki003 .

Feel free to ask if there are anything that needs explaining.

rogical’s picture

I think you can have a talk with this module SinaWeibo, both use weibo.com service.

xenyo’s picture

Hi and thx for comment.

I am aware of Sinaweibo and have used it on the same sites as this module. They do 2 separate things. SinaWeibo is a log-in/sign-in module with Weibo Account and this module is a module to enable a site to Autopost selected Content Types to their Weibo Profile page.

Imagine Facebook, SinaWeibo is a Connectwith Facebook Module, and this module is a Module that posts to your company's Page whenever you update your Company Blog.

Another reason why we did not ask to add this feature to the SinaWeibo module, apart from it being 2 different things is that, SinaWeibo uses the previous Weibo API and we wanted to use the new version.

Hope the above, clarifies the differences.

xenyo’s picture

Was there any more comments or anything else that is required from us to make review easier?

Thanks

rogical’s picture

Yes, check the Review bonus to speed your review.

xenyo’s picture

Priority: Normal » Major
xenyo’s picture

Priority: Major » Critical

Will get started on Review Bonus when I finish my current workload. Thx Rogical.

klausi’s picture

Priority: Critical » Normal
Status: Needs review » Needs work
StatusFileSize
new2.92 KB

Sorry for the delay, but you have not listed any reviews of other project applications in your issue summary as strongly recommended in the application documentation.

Review of the 7.x-1.x branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Get a review bonus and we will come back to your application sooner.

manual review:

  1. SinaOpenApi.php appears to be 3rd party code. 3rd party code is not generally allowed on Drupal.org and should be deleted. This policy is described in the getting involved handbook. It also appears in the terms and conditions you agreed to when you signed up for Git access, which you may want to re-read, to be sure you're not violating other terms. The Libraries API module is a recommended method for adding 3rd party dependencies without directly including the code on Drupal.org.
  2. weibo_post_uninstall(): doc block is wrong, see http://drupal.org/node/1354#hookimpl , same on other hook implementations.
  3. "'#description' => t('.'),": empty description, so remove it.
  4. weibo_post_log_overview(): do not create image markup yourself, use theme('image', ...) instead.
  5. weibo_post_log_overview(): the third party returned text has to be considered as user provided input and has to be sanitized in order to avoid XSS exploits. Please see http://drupal.org/node/28984 . Or has it been sanitized along the way somewhere?
lildragon’s picture

Hi,

Is this module supported in Drupal 6? thanks.

xenyo’s picture

Hi,

Its just D7 at the moment and actually still sandbox as we have been really busy lately. I'll try to get this updated as soon as we can.

Regards,

Matt

xenyo’s picture

Issue summary: View changes

change git clone

xenyo’s picture

Issue summary: View changes

update 3rd party link

xenyo’s picture

Issue summary: View changes

Added reviews of other projects

xenyo’s picture

Status: Needs work » Needs review

Changed updated and commited.

PAREVIEW: http://ventral.org/pareview/httpgitdrupalorgsandboxxenyo1447074git

In reply to Klausi's manual review (comment 14)

  1. SinaOpenApi.php appears to be 3rd party code. 3rd party code is not generally allowed on Drupal.org and should be deleted. This policy is described in the getting involved handbook. It also appears in the terms and conditions you agreed to when you signed up for Git access, which you may want to re-read, to be sure you're not violating other terms. The Libraries API module is a recommended method for adding 3rd party dependencies without directly including the code on Drupal.org.
  2. SinaOpenApi.php removed.

  3. weibo_post_uninstall(): doc block is wrong, see http://drupal.org/node/1354#hookimpl , same on other hook implementations.
  4. Edited but i am not sure if that is what was meant.

  5. "'#description' => t('.'),": empty description, so remove it.
  6. Removed

  7. weibo_post_log_overview(): do not create image markup yourself, use theme('image', ...) instead.
  8. image markup is replaced by theme function.

  9. weibo_post_log_overview(): the third party returned text has to be considered as user provided input and has to be sanitized in order to avoid XSS exploits. Please see http://drupal.org/node/28984 . Or has it been sanitized along the way somewhere?
  10. data from 3rd party are filtered by check_plain().

Thanks for the review and i hope everything is covered.

xenyo’s picture

Issue summary: View changes

add project review

xenyo’s picture

Issue tags: +PAreview: review bonus

Added tag: PAReviews: review bonus as outlined on http://drupal.org/node/1410826

rogical’s picture

" so we need you to review other project applications .."

donatasp’s picture

@xenyo: two reviews you've made are just links to ventral.org, and one is request for better issue description although information you ask is given in first comment. in general, manual in-depth reviews are expected of you.

donatasp’s picture

Assigned: Unassigned » donatasp
donatasp’s picture

Assigned: donatasp » Unassigned
Status: Needs review » Needs work

Manual review

It is confusing that you named your module weibo_autopost, but
file names and module prefix is weibo_post. I'm not sure whether
you're required to fix this for approval but I think you should.

Documentation
Read http://drupal.org/node/161085 for a documentation guidelines. You
should:
  • Clean README.txt of HTML markup. Structure content. See examples
    under "Style" here http://drupal.org/node/447604.
  • Implement hook_help().
  • Document all functions using Doxygen comment style and other Drupal
    requirements:
    • There is no such hook_form_submit(). weibo_post_submit() is a
      submit handler.
    • weibo_post_listing() and weibo_post_log_overview() need @return
      keyword.
    • weibo_post_uninstall() is implementation of hook_uninstall().
Code
It is generally a bad design decision to use global variables. Also,
there is no need to use global $_upload_params. Node form keys are
assigned to $node object as fields and are available for you in
hook_node_insert() and hook_node_update().

weibo_post_node_insert() and weibo_post_node_update() differs in one
line only. You should refactor this into separate general function.

Check if (empty($language)) { in weibo_post_submit()
always succeeds. There is no $language defined.

You are checking for field_image and field_logo. This is not user
friendly and makes assumptions that won't hold for a majority of node
types in real world. You should make image field configurable.

Also, there will be no need for ugly and wrong access of
$form['field'][$language][0]['#file'] once you move this code to
hook_node_insert(), hook_node_update() and use field_get_items() as
Maxorete suggested.

xenyo’s picture

Status: Needs work » Needs review

Thanks Donatasp,

Following your comments, we made pretty major updates/corrections to the module. Our reply to your comments as below;

It is generally a bad design decision to use global variables. Also,
there is no need to use global $_upload_params. Node form keys are
assigned to $node object as fields and are available for you in
hook_node_insert() and hook_node_update().

Global variables no longer used.

weibo_post_node_insert() and weibo_post_node_update() differs in one
line only. You should refactor this into separate general function.

Noted, Module now using node_presave

Check if (empty($language)) { in weibo_post_submit()
always succeeds. There is no $language defined.

Noted, now using field api

You are checking for field_image and field_logo. This is not user
friendly and makes assumptions that won't hold for a majority of node
types in real world. You should make image field configurable.

Added function for admin to choose image field for post

Also, there will be no need for ugly and wrong access of
$form['field'][$language][0]['#file'] once you move this code to
hook_node_insert(), hook_node_update() and use field_get_items() as
Maxorete suggested.

Noted, now using field api

Additionally, added dependency of SinaWeibo Module.

Thanks again for your time to review.

xenyo’s picture

Also made D6 version (client request). Put it in Sandbox in case anyone wants to use.

klausi’s picture

Issue tags: -PAreview: review bonus

Removing review bonus tag, you have not done any manual review, you just posted the output of an automated review tool. Make sure to read through the source code of the other projects.

Also, when finishing your review comment also set the issue status either to "needs work" (you found some problems with the project) or "reviewed & tested by the community" (you found no flaws).

xenyo’s picture

Issue tags: +PAreview: review bonus

Noted and please find manual review of a project;

http://drupal.org/node/1447164#comment-6176252

Will try to find time to do more.

Added tag: PAReviews: review bonus as outlined on http://drupal.org/node/1410826

xenyo’s picture

Issue summary: View changes

add review

xenyo’s picture

xenyo’s picture

Issue summary: View changes

Added review

klausi’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

Thanks for your reviews. when finishing your review comment also set the issue status either to "needs work" (you found some problems with the project) or "reviewed & tested by the community" (you found no flaws).

manual review:

  1. weibo_autopost_uninstall(): this is a hook implementation and should be documented as such. See http://drupal.org/node/1354#hookimpl
  2. "t('Connect your account ') . $weibo_connect_link;": do not concatenate translatable strings and variables, use placeholders with t() instead.
  3. "&& !empty($node->weibo_autopost_enable) ? ($node->weibo_autopost_enable == 1) : 0" is the same as "&& !empty($node->weibo_autopost_enable)"?
  4. weibo_autopost_node_presave(): use url() to create the node URL, then you don't need the global base_url.
  5. weibo_autopost_node_presave(): global $_upload_params; is never used, remove it.
  6. weibo_autopost_listing(): use check_url() instead of check_plain() to validate the image URL.
  7. "theme_image($variables);": do not hardcode this theme function use theme('image', ...) instead.
  8. weibo_autopost_associate_form(): this is not a hook implementation? See http://drupal.org/node/1354#forms on how to document form generating functions.
  9. "'#title' => t($content_type->type),": you are using the machine name here, so this is not vulnerable to XSS exploits. However, if you should ever decide to use the name of the node type you will have to sanitize it (see http://drupal.org/node/28984 )

Although you should definitively fix those issues, they are no blockers so I think this is RTBC. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

xenyo’s picture

Committed with fixes as suggested.

Thanks Klausi and other commenters, really appreciate your time and patience. The process has actually been quite fun and educational.

patrickd’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contribution and welcome to the community of project contributors on drupal.org!

I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

As you continue to work on your module, keep in mind: Commit messages - providing history and credit and Release naming conventions.

Thanks to the dedicated reviewer(s) as well.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture