定制 ryancwalsh/stack-exchange-backup-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ryancwalsh/stack-exchange-backup-laravel

Composer 安装命令:

composer require ryancwalsh/stack-exchange-backup-laravel

包简介

My aim is to back up all of my questions and answers and anything else valuable in my accounts across all of the StackExchange sites (StackOverflow, SuperUser, https://apple.stackexchange.com/, https://askubuntu.com/, etc).

README 文档

README

Allows you to export JSON files of your most important data (questions, answers, comments, favorites) from each of your Stack Exchange sites (Stack Overflow, Super User, Server Fault, etc).

Installation

  1. I think this project requires PHP 7.3 or later, so be sure that your system complies.
  2. Sign up at https://stackapps.com/apps/oauth/register to receive a Client ID, Client Secret, and Key. (It's free, easy, and fast.)
  3. Create a Laravel project, and make sure that it works: https://laravel.com/docs/6.0/installation (e.g. composer create-project --prefer-dist laravel/laravel stackExchangeBackupDemo)
  4. Add this package into your Laravel project: vagrant@vboxHomestead:~/Code/MyLaravelProject$ composer require ryancwalsh/stack-exchange-backup-laravel:^2.0.6 (but use whatever the latest release tag number is at https://github.com/ryancwalsh/StackExchangeBackupLaravelPHP/releases).
  5. Run php artisan vendor:publish, and if it gives you a choice, choose to publish from this package.
  6. Edit your Laravel project's .env file to have your own StackApps values. A non-working sample is below.
  7. Run php artisan exportStackExchange. There are also these options available:
    1. php artisan exportStackExchange --forgetCache is an available option to clear the cached access code value.
    2. php artisan exportStackExchange --code="YOUR_CODE" is an available option to provide a code that you've already retrieved from StackExchange.
    3. php artisan exportStackExchange --S3=false is an available option to skip uploading to Amazon S3.
  8. Following the instructions in the terminal, you'll use your browser to visit a URL that will provide you with a temporary access token to paste into the terminal.
  9. Finished! The JSON files will appear in your /storage/app/StackExchange folder, and a zip of those files will appear in S3.
# These are sample .env values:
STACKAPPS_CLIENT_ID=12227
STACKAPPS_CLIENT_SECRET=ydxGSDFHDF4DtZqCesr)yJIw((
STACKAPPS_KEY=JuWsTgfG2CqjdghkhdgBkQ((
AWS_ACCESS_KEY_ID=AKIAmb3mbn56mn6
AWS_SECRET_ACCESS_KEY=jl234k5jl23k45j23lj5
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=xyz

If You Use This Package, Let Me Know!

This is the first package that I've ever made, and I'm super curious if anyone will ever use it. If you do try it out, I'd love for you to open an issue to say hi (and of course to tell me any suggestions you have).

If You Want To Get Creative...

Visit https://api.stackexchange.com/docs to read the docs, and you can modify ExportStackExchangeHelper.php to do whatever you want. The Stack Exchange API is great.

Other Resources That Helped Me

Problems for Ryan locally. Workaround / hack.

The easier way to do what is shown in "Older notes"

2024-07-06_135807_ET

  1. In WSL (currently Ubuntu 20.04 LTS), and the terminal will ask you for your password. Provide it. Otherwise you'll get nameserver errors later. https://bitbucket.org/rcwalsh/issues/issues/500/temporary-failure-in-name-resolution-on
  2. Run cd /mnt/c/code/stackExchangeBackupDemo2 && php artisan exportStackExchange --forgetCache.
  3. Visit https://reqbin.com/post-online and log in.
  4. In the left panel, click Saved > stackoverflow.
  5. change value of "code" to the value from the URL from the first step.
  6. Click send.
  7. From the new URL, copy the access token.
  8. Paste the access token into the "get" function (see FIXNOW) in C:\code\stackExchangeBackupDemo2\vendor\ryancwalsh\stack-exchange-backup-laravel\src\ExportStackExchangeHelper.php.

#11 (comment)

https://stackapps.com/questions/10497/suddenly-getting-couldnt-parse-client-id?noredirect=1#comment20685_10497

Older notes (stale?)

https://stackapps.com/questions/10497/suddenly-getting-couldnt-parse-client-id#comment20685_10497 By posting into reqbin.com/post-online in x-www-form-urlencoded mode instead of application/json, I'm able to retrieve an access_token.

url: https://stackoverflow.com/oauth/access_token/json

payload: client_id=(from_laravel.log)__ client_secret=(from_laravel.log)__ code=(from_browser_URL)__ redirect_uri=https://stackexchange.com/oauth/login_success

Get the access_token from the result.

Put a line like return json_encode(['access_token'=> 'Ke4q2tsof5yfPUTf']); as the first line of public function getAccessTokenJson() in C:\code\stackExchangeBackupDemo2\vendor\ryancwalsh\stack-exchange-backup-laravel\src\ExportStackExchangeHelper.php.

In a new VSC window, open C:\code\stack-exchange-backup-laravel\src\ExportStackExchangeHelper.php in its project.

Note that this is NOT symlinked to C:\code\stackExchangeBackupDemo2\vendor\ryancwalsh\stack-exchange-backup-laravel\src\ExportStackExchangeHelper.php

ryancwalsh/stack-exchange-backup-laravel 适用场景与选型建议

ryancwalsh/stack-exchange-backup-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26 次下载、GitHub Stars 达 4, 最近一次更新时间为 2018 年 09 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ryancwalsh/stack-exchange-backup-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ryancwalsh/stack-exchange-backup-laravel 我们能提供哪些服务?
定制开发 / 二次开发

基于 ryancwalsh/stack-exchange-backup-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 26
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2018-09-08