Hello i'm trying to post on a user's wall a big foto article like this one
I have tried this code
$post = array(
'access_token' => $row['user_token'],
'message' => 'Hello world ',
'link' => $row['url'],
//'name' => "This is my title",
//'caption' => "My Caption",
//'description' => "Some Description...",
'picture' => $imgurl
//'image' => $row['img']
);
$res = $facebook->api("/" . $row['facebook_id']. "/feed", 'POST', $post);
and it produces a small picture like this one
And this code produces nothing
/* make the API call */
$response = $facebook->api(
"/me/objects/article",//or /$user_id/objects/article
"POST",
array (
'fb:app_id' => '302184056577324',//change with stuff
'og:type' => 'article',
'og:url' => 'Put your own URL to the object here',
'og:title' => 'Sample Article',
'og:image' => 'https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png',
)
);
/* handle the result */
Can someone provide working code or explain like you would to a 7 years old ?
If you want the image to be displayed at the larger size, the source image has to be at least 1200x630px as described at https://developers.facebook.com/docs/opengraph/howtos/maximizing-distribution-media-content#images and already pointed out by CBroe...
Related
I have problem with facebook api and can't find any information.
I want create link (example #Username) in status, with Graph API.
My code:
$response = $facebook->api("/" . $data['pageId'] . "/feed", 'POST',
[
'message' => $messageContainer['message'],
'link' => 'https://example.com/reviews',
'name' => $messageContainer['subject'],
'description' => $messageContainer['description'],
'picture' => 'https://example.com/uploads/dealer/' . $messageContainer['logo'],
]
);
$messageContainer['message'] = 'Some text #Username';
but text wasn't created as link in status only as string.
May be it's impossible?
I'm trying to post a message with picture (from a public URL, not from my albums) to group's wall:
$response = $facebook->api("/$group_id/feed", "POST", array(
'access_token=' => $access_token,
'message' => 'This is a test message',
'picture' => 'http://d24w6bsrhbeh9d.cloudfront.net/photo/agydwb6_460s.jpg',
)
);
Everything is fine, but I can't see a picture itself:
What am I doing wrong? Thanks in advance!
While posting a feed, you must specify a link along with a picture if want to add a picture to the feed; else its not a feed. Logical right?
Code:
'access_token=' => $access_token,
'message' => 'This is a test message',
'link' => '{link-to-share}',
'picture' => 'http://d24w6bsrhbeh9d.cloudfront.net/photo/agydwb6_460s.jpg',
If you dont want link, but just a picture, then you should simply upload the picture instead- by using /photos
Code:
$response = $facebook->api(
"/$group_id/photos",
"POST",
array (
'url' => '{image-url}',
)
);
im posting to a users wall, i have the id and everything else, but i cannot seem to "tag" friends, here is the code (I followed their documentation https://developers.facebook.com/docs/reference/api/user/#posts):
$tags = $tag1 . $tag2 . ',someID';
// tag 1 and tag 2 are also IDs of users, seperated by a comma only, no whitespace
$place = '110343502319180';
$attachment = array(
'access_token' => $access_token,
'message' => $message,
'link' => $link,
'name' => $title,
'description' => $desc,
'picture'=>$pic,
'place'=>$place,
'tags'=>$tags,
'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
);
$post_url = '/' . $row['uid'].'/feed';
$postResult = $facebook->api($post_url, 'post', $attachment );
I specify a place, and 3 user IDs, to tag, it does not work.
For info, the story does get posted, but the tag and the location are not defined in it..
I am trying to post dynamic data to facebook wall.
I downloaded facebook api for php.
First of all, as for testing, I use below code.
<?php
// Remember to copy files from the SDK's src/ directory to a
// directory in your application on the server, such as php-sdk/
require '../src/facebook.php';
$config = array(
'appId' => 'myAPPID',
'secret' => 'MySecretCode'
);
//'access_token' => $access_token = $facebook->getAccessToken(),
$facebook = new Facebook($config);
$attachment = array(
'access_token' => 'my_tokenkey',
'message' => 'Test Message offline test message',
'name' => 'Name Test offline test...',
'description' => 'here goes description and links http:anotherfeed.com | http://facebook.com/anotherfeed',
'caption' => 'this is caption for action link',
'picture' => 'http://www.google.com/tv/images/slivetv.png',
'link' => 'www.yahoo.com',
'properties' => array(
array('text' => 'test link 1', 'href' => 'http://anotherfeed.com/?ref=1'),
array('text' => 'test link 1', 'href' => 'http://anotherfeed.com/?ref=1'),
),
);
try {
$facebook->api('/me/feed', 'POST', $attachment);
} catch(FacebookApiException $e) {
echo $e;
# handling facebook api exception if something went wrong
}
?>
As for my program requirement, I want my program to post data to facebook's wall whether facebook is online or offline.
But when I try this code, I get error.
OAuthException: An active access token must be used to query information about the current user.
Could anyone please give me suggestions?
I've serached a little but I didn't find anything that could solve my problem.
I've managed to post on page as page admin, link is added correctly, but image isn't attached. My code:
Blahblah authentication, etc.
$attachment = array(
'message' => 'text',
'name' => 'Name',
'link' => 'http://somelink.com',
'description' => '',
'access_token' => $ACCESS_TOKEN
);
if(something) $attachment['media'] = array(array('type'=>'image', 'src'=>'http://'.$_SERVER['HTTP_HOST']."/media/file/image_by_id/".$data['thumb_file_tree_id'].'/?w=400&h=500', 'href'=>'http://somelink.com'));
try {
if($facebook->api('/XXX/feed', 'post', $attachment))
{
echo 'Hooray, ok';
}
} catch (FacebookApiException $e) {
echo 'Damn';
}
Result: Correctly posted news with link ('Hooray, ok'), but without image. Can it be due to PHP generated image, and not png/jpg/gif extension? I've added some additional headers like etag, accepted-ranges, last modified, etc. What am I doing wrong (again)?
'Something' is true, checked with print_r whole attachment array.
E: Again removed [0]
To just attach an image, you can use the picture key in your attachment.
$attachment = array(
'message' => 'text',
'name' => 'Name',
'link' => 'http://somelink.com',
'description' => '',
'access_token' => $ACCESS_TOKEN,
'picture' => 'http://example.com/example.jpg'
);