Import user picture from twitter during reregistration .
You can configure either importing twitter picture or not via twitter signin configuration page.
To use the features above, you have to patch twitter_signin.module and twitter_signin.pages.inc.
The patch files are based on the twitter 3.3.

to apply patch go to twitter directory and run this command patch -p0 < [patch-path]

Comments

juampynr’s picture

Status: Patch (to be ported) » Needs review

Setting the right status.

13rac1’s picture

Version: 7.x-3.3 » 7.x-5.x-dev
Status: Needs review » Needs work

Patch applies with offset to 7.x-5.x. Should be a git apply patch.

$ git apply twitter_signin_import_picture.patch 
twitter_signin_import_picture.patch:39: trailing whitespace.
 
twitter_signin_import_picture.patch:48: trailing whitespace.
      $source_url = $twitter_account->profile_image_url; 
error: twitter_signin.module: No such file or directory
error: twitter_signin.pages.inc: No such file or directory
$ patch -p0 < twitter_signin_import_picture.patch 
patching file twitter_signin/twitter_signin.module
Hunk #1 succeeded at 131 (offset -4 lines).
Hunk #2 succeeded at 144 (offset -4 lines).
Hunk #3 succeeded at 163 (offset -4 lines).
Hunk #4 succeeded at 247 (offset 4 lines).
patching file twitter_signin/twitter_signin.pages.inc
  1. This functionality should be optional for the user even if enabled site-wide.
  2. If the image fails size validation, the user account is updated anyway. The file_validate_image_resolution() return value is ignored.
+      // Check to make sure the picture isn't too large for the site settings.
+      $max_dimensions = variable_get('user_picture_dimensions', '85x85');
+      file_validate_image_resolution($picture_file, $max_dimensions);
+      // Update the user record.
+      $picture_file->uid = $account->uid;
n20’s picture

with the patch applyed, fetching of the picture works only at second login for me. On the initial login/authorization of the app there is no picture fetched.

n20’s picture

I figured out that for a brand new user loginin/signup and authorizing the twitter app for the first time, twitter_account_save() is called after twitter_signin_get_picture(). But in twitter_signin_get_picture() we try to load already the twitter user with twitter_account_load(). So basically we try to load the data from table twitter_user before it's even saved.

I have trouble to find what exactly calls twitter_account_save() and when.

n20’s picture

Ok, i created a patch for 7.x-6.x-dev wich includes the previous patch. The picture import works now also on the very first signup/login... at least for me.

Instead of $response['user_id'] i used $account->name when loading the twitter account of the database. Also $_SESSION['twitter']['values'] wasn't set when running _twitter_signin_add_account(). Because of this the entrys for the table twitter_account are filled always after we are already processed twitter_signin_get_picture. However, i wonder where the $_SESSION should have benn filled with values? I just set them right before we save the user with the response data.

Apply patch with patch < [patch-path] when downloaded to twitter_signunp or with patch -p0 < [patch-path] when in twitter module root.

cheers, N20

svanou’s picture

Issue summary: View changes

Hi,
I tried the patch but it seems the picture disappear when user create a password with email and login again after via twitter.
Would you know how to fix this :) please ?
Thanks! Sylvain

svanou’s picture

ok sorry this happen when a user changes his username. For now I will disallow my user to do so :P
thanks!

svanou’s picture

hey,
I'm trying to get a bigger picture from my users twitter account, i tried to play with max image size but could not make it work. Do you have any ideas on how to achieve this please ? An example (my profile) : http://bit.ly/1A8GkNr Thanks a lot ! Sylvain

svanou’s picture

I think i'm getting closer now https://dev.twitter.com/rest/reference/get/users/show by default twitter will send you the 48x48 pic, instead the url should be appended by _bigger or other arguments. Anyone know how can we change this please?

damienmckenna’s picture

Status: Needs work » Needs review

The last submitted patch, twitter_signin_import_picture.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 5: twitter_signin-import_twitter_picture-1840298.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new3.98 KB

Rerolled.

Status: Needs review » Needs work

The last submitted patch, 13: twitter-n1840298-13.patch, failed testing.