PHP Classes

File: examples/plurk.php

Recommend this page to a friend!
  Classes of Chun-Sheng, Li   PHP Social Network Sync   examples/plurk.php   Download  
File: examples/plurk.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP Social Network Sync
Synchronize post feeds between social networks
Author: By
Last change:
Date: 7 months ago
Size: 1,461 bytes


Class file image Download
* This is about the Plurk posting feeed sample code
$key = parse_ini_file(__DIR__.'/../api-key.ini');
define('NICKNAME', $key['user_name']);
define('PASSWORD', $key['user_password']);
define('USER_ID', $key['user_id']);

$message = "????????????????";
$message .= PHP_EOL.'';
$message = urlencode($message);

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');

// get login token and try to login the Plurk website
curl_setopt($ch, CURLOPT_URL, '');
$response = curl_exec($ch);
$posString = strpos($response, '<input type="hidden" name="login_token" value="') + 47;
$token = substr($response, $posString, strpos($response, '"', $posString) - $posString);
curl_setopt($ch, CURLOPT_URL, '');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'nick_name='.NICKNAME.'&password='.PASSWORD.'&login_token='.$token);

// post the feed
curl_setopt($ch, CURLOPT_URL, '');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'qualifier=says&content='.$message.'&lang=tr_ch&no_comments=0&uid='.USER_ID);
$httpCode = curl_getinfo($ch)['http_code'].PHP_EOL;