Skip to content

Instantly share code, notes, and snippets.

@ytkhs
Created June 4, 2011 17:18
Show Gist options
  • Save ytkhs/1008086 to your computer and use it in GitHub Desktop.
Save ytkhs/1008086 to your computer and use it in GitHub Desktop.
push notification to iPhone via im.kayac.com with password, and open Twitter.
<?php
define('USERNAME', 'xxxxxxxx');
define('PASSWORD', 'xxxxxxxxxxxxxx');
define('END_POINT', 'http://im.kayac.com/api/post/'.USERNAME);
$postMessage = urlencode('東京スカイツリーにきたよ!');
$data = array(
'message' => 'Push from im.kayac.com',
'password' => PASSWORD,
'handler' => 'twitter://post?message='.$postMessage
);
$content = http_build_query($data, '', '&');
//header
$header = array(
'Content-Type: application/x-www-form-urlencoded',
'Content-Length: '.strlen($content)
);
$context = array(
"http" => array(
'method' => 'POST',
'header' => implode("rn", $header),
'content' => $content
)
);
echo file_get_contents(END_POINT, false, stream_context_create($context));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment