ユーザーのウォールに投稿する場合:
Javascript の使用:
function doPost() {
var params = {};
params['message'] = "<USER> started using <YOUR APP NAME>";
params['name'] = '<YOUR APP NAME>';
params['description'] = '<DESCRIPTION ABOUT YOUR APP>';
params['link'] = "<LINK TO YOUR WEBSITE>";
//ON CLICKING THE POST WHERE YOU WANT USER TO BE REDIRECTED e.g. www.yoursite.com
params['picture'] = '<PATH OF PICTURE THAT YOU WANT TO BE DISPLAYED ON THE POST>';
FB.api('/me/feed', 'post', params, function(response) {
if(!response || response.error) {
console.log('ERROR OCCURED '+response.error);
}
else {
console.log('POSTED SUCCESSFULLY');
}
}}
PHP の使用:
$ret_obj = $facebook->api('/me/feed', 'POST',
array( 'link' => '<LINK TO YOUR WEBSITE>',
'message' => '<USER> started using <YOUR APP NAME>',
'description' => "<DESCRIPTION ABOUT YOUR APP>")); //Returns the POST ID.
ユーザーの画像を取得する場合:
$fbImageUrl = https://graph.facebook.com/**<FBUSER_ID>**/picture?type=<VALUE>
(また)
$fbImageUrl = https://graph.facebook.com/**<FBUSER_NAME>**/picture?type=<VALUE>
'small' または 'normal' または 'large' または 'square' のいずれかです。
//画像を保存する場合:
$localFilePath = 'pathToImagesFolder/<SOME_NAME>.jpg'; //Use relative path.
$fbImage = file_get_contents($fbImageUrl); //Fetches the image and stores it in variable.
file_put_contents($file1, $img1); //Will save the image in the path specified.