Skip to content

Instantly share code, notes, and snippets.

View howyi's full-sized avatar
🐔

niwatori / Hayashi Takuya howyi

🐔
View GitHub Profile
@howyi
howyi / Save images from URL.py
Last active August 29, 2015 14:24
Save images from URL
#Python 3.4.3
import sys
import urllib
def getImage(save_directory,url):
img = urllib.request.urlopen(url)
localfile = open(save_directory + url[url.rfind('/')+1:], 'wb')
localfile.write(img.read())
img.close()
@howyi
howyi / SQL(INSERT INTO) with PDO.php
Created July 11, 2015 07:10
SQL(INSERT INTO) with PDO
<-- PHP 5.6.7 -->
<form action="" method="post">
name: <input type="text" name="name" />
age: <input type="text" name="age" />
<input type="submit"/>
</form>
<?php
$dsn = "mysql:dbname=databese;host=localhost";
$user = "username";
@howyi
howyi / Search tweets(userstream) with tweepy.py
Created July 11, 2015 07:39
Search tweets(userstream) with tweepy
# Python 3.4.3
# tweepy 3.3.0
# coding: utf-8
import sys
import webbrowser
import tweepy
from tweepy.streaming import StreamListener
from tweepy import Stream
import shelve
@howyi
howyi / Get twitter authorize URL with twitterOAuth.php
Last active June 21, 2018 16:40
Get twitter authorize URL with twitterOAuth
<?php
session_start();
require "twitteroauth/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
define('CONSUMER_KEY', 'hoge');
define('CONSUMER_SECRET','foo');
define('OAUTH_CALLBACK', 'http://localhost');
@howyi
howyi / Tweet with twitterOAuth.php
Created July 16, 2015 03:25
Tweet with twitterOAuth
<?php
session_start();
require "twitteroauth/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
$tw = "Tweet test";
define('CONSUMER_KEY', 'hoge');
define('CONSUMER_SECRET','foo');
@howyi
howyi / authorize.php
Last active August 29, 2015 14:25
Build authorize URL
<html>
<head>
<title>Authorize</title>
</head>
<body>
<?php
session_start(); #トークンの共有にセッション関数を使うので、全てのphpの最初にsession_start();を入れる
#twitterOAuthの読み込み
require "twitteroauth/autoload.php";
@howyi
howyi / callback.php
Last active August 29, 2015 14:25
Save access_token
<html>
<head>
<title>Callback</title>
</head>
<body>
<?php
session_start();
require "twitteroauth/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
@howyi
howyi / tweet.php
Created July 16, 2015 05:23
Tweet
<html>
<head>
<title>Tweet</title>
</head>
<body>
<pre>
<?php
session_start();
require "twitteroauth/autoload.php";
@howyi
howyi / initialize.php
Created July 16, 2015 05:23
Initialize
<?PHP
#初期設定を共通化して手間を省く(hogeとfoo,barは差し替え必須)
define('CONSUMER_KEY', 'hogehogehoge');
define('CONSUMER_SECRET','foofoofoo');
define('OAUTH_CALLBACK', 'http://localhost/barbarbarbar/callback.php');
?>
@howyi
howyi / Authorize.py
Created September 7, 2015 11:25
Authorize and save access token
# coding: utf-8
# python 3.4.3
# tweepy 3.3.0
import webbrowser
import tweepy
import shelve
consumer_key = 'hogehogehoge'