curl -F 'access_token=...' \
-F 'message=Hello, Arjun. I like this new API.' \
https://graph.facebook.com/arjun/feed
文档上说我需要发一个到墙上才能发布。
// Your POST data
$data = http_build_query(array(
'param1' => 'data1',
'param2' => 'data2'
));
// Create HTTP stream context
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => $data
)
));
// Make POST request
$response = file_get_contents('http://example.com', false, $context);
使用PHP的curl*函数族。
例如:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/arjun/feed');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('access_token' => 'my token',
'message' => 'Hello, Arjun. I like this new API.'));
curl_exec($ch);