dongyuji7309 2015-12-29 17:24
浏览 38
已采纳

Laravel Socialite HTTPS twitter头像

I am using laravel 5.0 and utlising the socialite extension to enable twitter login. I encountered a problem with the retrieval of the users twitter profile picture.

The url for the profile picture I receive from twitter is in the following format.

http://pbs.twimg.com/profile_images/662983942727999489/q5I9DMyE_normal.png

This is saved to my db and shown when the user logs into their account. The problem is this image is serving over HTTP and is producing browser warnings when users are accessing their account, as not all the page content is served over HTTPS.

Is there any way to save the twitter profile picture with HTTPS compared to HTTP.

 $user = User::create([
            'provider_id' => $userData->id,
            'name' => $userData->name,
            'username' => $userData->nickname,
            'email' => $userData->email,
            'avatar' => $userData->avatar,
            'active' => 1,
        ]);

I save the user twitter data to my db as shown above and it the $userData->avatar part which is saving the HTTP url.

I can't seem to work a way around this and can't find much documentation on the issue. Any help would be appreciated.

  • 写回答

1条回答 默认 最新

  • duanfeng7756 2015-12-29 19:02
    关注

    Well, verifying this url, it seems simple https:// for the same url works, so you can do:

    $user = User::create([
        'provider_id' => $userData->id,
        'name' => $userData->name,
        'username' => $userData->nickname,
        'email' => $userData->email,
        'avatar' => str_replace('http://','https://',$userData->avatar),
        'active' => 1,
    ]);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b