Skip to content

Instantly share code, notes, and snippets.

@afutseng
Created July 10, 2014 13:44
Show Gist options
  • Save afutseng/7b8f0dba567ef951a8dd to your computer and use it in GitHub Desktop.
Save afutseng/7b8f0dba567ef951a8dd to your computer and use it in GitHub Desktop.
<?php
require '../vendor/autoload.php';
+ use GuzzleHttp\Client;
+ use GuzzleHttp\Cookie\CookieJar;
+
+
+ $url = 'https://www.ptt.cc/bbs/Gossiping/M.1404887907.A.886.html';
$client = new Client();
+
+ $jar = new CookieJar();
+ $client->setDefaultOption('cookies', $jar);
+
+ try {
+ $response = $client->post('https://www.ptt.cc/ask/over18', [
+ 'body' => [
+ 'yes' => 'yes',
+ 'from' => '/bbs/Gossiping/M.1404887907.A.886.html'
+ ]
+ ])->getBody();
+ } catch (Exception $e) {
+ echo $e->getMessage() . PHP_EOL;
+ }
+
$response = $client->get($url)->getBody();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment