{"id":20159745,"url":"https://github.com/yukihirai0505/twitter-bot-sample","last_synced_at":"2026-06-09T10:31:57.632Z","repository":{"id":84910100,"uuid":"57427220","full_name":"yukihirai0505/twitter-bot-sample","owner":"yukihirai0505","description":"A sample project to start twitter bot with php","archived":false,"fork":false,"pushed_at":"2017-08-30T09:35:47.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-30T01:34:33.405Z","etag":null,"topics":["bot","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yukihirai0505.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-30T04:35:31.000Z","updated_at":"2020-03-07T21:36:04.000Z","dependencies_parsed_at":"2023-11-23T07:30:45.055Z","dependency_job_id":null,"html_url":"https://github.com/yukihirai0505/twitter-bot-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yukihirai0505/twitter-bot-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yukihirai0505%2Ftwitter-bot-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yukihirai0505%2Ftwitter-bot-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yukihirai0505%2Ftwitter-bot-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yukihirai0505%2Ftwitter-bot-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yukihirai0505","download_url":"https://codeload.github.com/yukihirai0505/twitter-bot-sample/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yukihirai0505%2Ftwitter-bot-sample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34103355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","php"],"created_at":"2024-11-14T00:09:58.748Z","updated_at":"2026-06-09T10:31:57.611Z","avatar_url":"https://github.com/yukihirai0505.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# twitter_bot\n\nTwitterのdeveloper画面でアプリを作成\n\n[https://apps.twitter.com/](https://apps.twitter.com/)\n\nPHPでTwitterBotのサンプルを作成(勉強会用)\n\nまずは記録しておいた\n\n- Consumer Key (API Key)\n- Consumer Secret (API Secret)  \n- Access Token\n- Access Token Secret\n\nをconfig.phpに記述していきます。\n\n```config.php\n\n\n\u003c?php\ndefine('CONSUMER_KEY', '');\ndefine('CONSUMER_SECRET', '');\ndefine('ACCESS_TOKEN', '');\ndefine('ACCESS_TOKEN_SECRET', '');\n\n```\n\nこれでBot自体は既に動く状態になります。\nつぶやきたいメッセージなどはbot.phpで設定することができます。\n\n```\n\u003c?php\nrequire_once('twitteroauth/twitteroauth.php');\nrequire_once('config.php');\n$conn = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN,ACCESS_TOKEN_SECRET);\n\n/* messagesの中身でランダムにつぶやくメッセージを登録しておくことができる */\n$messages = array(\n  \"グー\",\n  \"チョキ\",\n  \"パー\",\n  );\n  \n  $random = rand(0, count($messages)-1);\n  \n  /* 固定メッセージの部分で毎回固定でつぶやきたい内容を設定することができる(ex HPのURLやハッシュタグなど */\n  $params = array(\n    'status' =\u003e $messages[$random].'[固定メッセージ]'\n    );\n  $result = $conn-\u003epost('statuses/update',$params);\n```\n  \nあとはbot.phpを実行すればAPIを通じてTwitterに投稿することができるようになります。\n  \n```\nphp bot.php\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyukihirai0505%2Ftwitter-bot-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyukihirai0505%2Ftwitter-bot-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyukihirai0505%2Ftwitter-bot-sample/lists"}