LoginSignup
32
34

More than 5 years have passed since last update.

PHPでPOST送信する方法

Last updated at Posted at 2012-12-26

Qiita API経由でQiitaのtokenを取得するにあたって、PHPでPOST送信を行う方法を調べてみた。

下記のコードでいけたので、メモしておく。
$url_nameと$passwordを正しく設定してやるとtokenが返ってくると思います。

<?php
$url = "https://qiita.com/api/v1/auth";
$data = array(
    'url_name' => $url_name,
    'password' => $password
);
$content = http_build_query($data);
$options = array('http' => array(
    'method' => 'POST',
    'content' => $content
));
$contents = file_get_contents($url, false, stream_context_create($options));

参考URL:
http://blog.totalsoft.co.jp/archives/3847364.html
http://qiita.com/docs

32
34
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
34