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?
Related
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}',
)
);
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...
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 have made a snake game using javascript and HTML5 Canvas element. It can be found at apps.facebook.com/snaqe_game. I have attained permissions and authorized the app for publish_feed or something using the Facebook Developer Documentation but the problem I am facing is while posting the player's score on his wall.
Please Note:
I do not have the PHP SDK
Please See: apps.facebook.com/mg-copter
Update Facebook News Feed using the Graph API in PHP
$data = array();
$data['post'] = array(
'access_token' => $access_token,
'message' => 'this is the message',
'picture' => 'http://sudocode.net/wp-content/uploads/2011/01/developer.facebook.com_banner-150x150.png',
'link' => 'http://sudocode.net/article/313/how-to-register-a-new-facebook-application/',
'name' => 'How to Register a New Facebook Application',
'caption' => 'sudocode | it looks like it works',
'description' => 'Here are some notes on how to register a new Facebook application.',
'actions' => '{"name": "Read the Article", "link": "http://sudocode.net/article/313/how-to-register-a-new-facebook-application/"}',
);
$response = xhttp::fetch("https://graph.facebook.com/{$profile_id}/feed", $data);
I have a couple of problems using facebook graph api.
1).
When i try to upload a photo i get the following error "(#324) Requires upload file".
$attachement = array(
'access_token'=> (...)',
'name' => 'uploaded foto',
'source' => 'C:\Documents and Settings\Username\Desktop\1.jpg'
);
$fb_foto = $fb->api('me/photos','POST',$attachement);
I am sure that source is correct. I have tried with a photo from the internet and not from mu local PC also.
2). How can i delete an object from facebook?. (a wall message for example).
I have tried this:
$fb->api('/post_id','POST',array('method'=> 'delete'));
But i get "unsupported POST request" error.
Any help would be appreciated.
EDIT: Here is the complete solution i found for upload photos to Facebook. You need to have the version 2.1.1 or above of PHP SDK
$fb = new Facebook(array(
'appId' => ...,
'secret' => ...,
'cookie' => true,
));
$fb->setFileUploadSupport(true);
$attachement = array(
'access_token'=> '...',
'name' => 'uploaded foto',
'source' => '#absolute_path_to_the_file'
);
$fb_foto = $fb->api('me/photos','POST',$attachement);
Concerning your 2nd problem, I remember reading somewhere about a DELETE request, instead of POST. See:
http://developers.facebook.com/docs/api#deleting
Read the documentation
curl -F 'access_token=...' \
-F 'source=#file.png' \
-F 'message=Caption for the photo' \
https://graph.facebook.com/me/photos
See how the source parameter is formatted?
$fb_foto = $fb->api('me/photos','POST',array(
'access_token' => (...)
, 'message' => 'Caption'
, 'source' => '#' . realpath( 'path/to/file' )
));
To delete photos, again the documentation has your answer: Issue a DELETE request
$fb->api( '/PHOTO_ID', 'DELETE' );
I'm using this method with the new php-sdk (v2.1.1, facebook-php-sdk-v2.1.1-0-g08909f3.zip) to upload a photo for a new event. The php code below creates the event.
$fname="/tmp/foo.jpg";
$attachment = array(
'access_token' => $facebook->getAccessToken(),
'name' => substr(event_name),
'description' => my_description,
'start_time' => my_start_time,
'link' => my_link,
'source'=> '#'.$fname
);
$result = $facebook->api('/me/events', 'POST', $attachment);