Flash size on publishing post by Graph API - facebook-graph-api

I use Facebook Graph API to post on user's wall. I also attach Flash application ("source" parameter) to it.
$data = array(
'name' => 'Test name',
'message' => 'Custom message',
'picture' => 'http://www.example.com/image.png',
'link' => 'http://www.example.com',
'description' => 'Description of the message',
'source' => 'http://www.example.com/flash.swf',
'access_token' => '... token_here ...',
'method' => 'post'
);
$ret = file_get_contents('https://graph.facebook.com/me/feed?'.http_build_query($data));
The problem that i can't set flash size. For example if use REST API, then you can define attached flash size by "expanded_width" and "expanded_height" parameters.
A few month ago when i tried to publish such post i saw that Facebook set flash size to 398x260, but today when i tried it again, i saw that Facebook set size to 398x224.
1) Does someone know if there is some way to define flash size in Graph API, like in REST API?
2) Is there some official documentation that provide default size of post attachment (source)?

Related

share link with original image size on facebook using facebook api and php sdk

I shared link on facebook using php sdk. I got image in facebook fixed size at post. But i want to original image size on my post. Below is my script.
<?php
require_once('facebook.php');
$config = array(
'appId' => 'xxxxx',
'secret' => 'xxx',
'allowSignedRequest' => true // optional but should be set to false for non-canvas apps
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
$access_token= $facebook->getAccessToken();
if($user_id!='')
{
try {
$facebook->api('/me/feed', 'POST', array( 'access_token' => $access_token, 'message' => 'Omg escape Games', 'link' => 'https://apps.facebook.com/omgescape/', 'picture' => 'https://www.omgescape.com/images/Johnny-320x300-jpg.jpg', 'name' => 'Jane Maxwell', 'caption' => 'Play this', 'description' => 'Play games on OMG Escape' ));
echo 'Successfully posted to Facebook Fan Page';
}
catch(Exception $e) {
echo $e->getMessage();
}
}
?>
When I share link through facebook api using php sdk, I got image like below.
But I want original image size in post. How to do that
Images shared to Facebook via the API will always appear the same size (as per your screenshot). Facebook decides (using a complex algorithm) if the image should be bigger to users when viewing the Stream - usually this depends on the usefulness or engagement of the share.
Naturally, larger images will get better engagement, so this is exclusively decided by Facebook. If users share something to their timeline manually (e.g. by posting a image or link using the form on Facebook) the images tent to be larger as it's counted as an "organic" share - something the user explicitly did.

Facebook FQL is deprecated, but there's no way to directly get friend_count with Graph API?

Using FQL I can easily get the friend count of a user with:
SELECT uid,friend_count FROM user WHERE uid IN (<list of user ids/>)
But it looks like with Graph API, I have to make requests until the pagination runs out, and then count how many results were returned using something like:
array(
'method' => 'GET',
'relative_url' => 'me/friends?access_token='. $token
)
I tried using
array(
'method' => 'GET',
'relative_url' => 'me/friends?summary=true&access_token='. $token
)
but that didn't work. Is there a single Graph API request that can get a user's friend count? If not, how do I make a feature request?
Facebook implemented this feature for the Graph API since the release of v2.1:
/friends edge on the User object now provides access to total friend count. This is retroactively supported in v2.0 as well.
Graph-API-v2.1

How to get the code for sharing the image of a facebook application to the users timeline?

Can I get the correct code of Facebook application, which allows to share or post the result image of the application to the users wall(Timeline).
Presently I am using the code below;-
$attachment = array(
'message' => 'this is my message',
'name' => 'This is my demo Facebook application! https://apps.facebook.com/whoisyourmillionare/',
'caption' => "Caption of the Post",
'description' => 'this is a description',
'picture' => 'http://www.nasa.gov/images/content/297522main_image_1244_946-710.jpg');
$result = $facebook->api('/me/feed/', 'post', $attachment);
and the out put is as per in the image 1
Actually I need to be as image 2

How to post a picture or link in an event via the Graph API?

$params = array(
'access_token' => $this->facebook->getAccessToken(),
'message' => 'My message',
'picture' => 'http://bookshop.fbsocialapps.com/images/homepage-illustration.jpg',
);
$post_id = $this->facebook->api('/'.$result['id'].'/feed','post',$params);
//$result['id'] is the id of the event
when I do that, only the message is published.
If I replace the $result['id'] by "me" it publishes correctly. I have the exact same problem when publishing a link.
Thanks for your help
It's a FB bug, although your code is a little off, you need to post to $result[id']/photos.
Subscribe to help get it fixed
https://developers.facebook.com/bugs/225316074217855?browse=search_4f2f7576c5bc32d87041759

Facebook PHP SDK 3.0 - How to get my page wall posts at any time?

I have been trying to read the news feed from a page that I have using an app that I'm coding.
Now I have had some issues trying to do this using the PHP SDK 3.0.
I am able to get the page information, but this is something that is publicly available any way.
My question is how do I get (read) the page wall posts? I'm assuming I have to grant permissions to my app to post to page, but how do I do this?
currently this is the code that I have
$appId = 'XXXXXXXXXXXXXXXXXX';
$secret = 'YYYYYYYYYYYYYYYY';
$pageId = 'ZZZZZZZZZZZZZZZZZZ';
$facebook = new Facebook(array(
'appId' => $appId,
'secret' => $secret
));
$pageProfile = $facebook->api($pageId);
$pagePosts = $facebook->api($pageId . '/posts/');
echo 'My Page profile';
print_r($pageProfile);
echo 'My Page wall';
print_r($userPosts);
Under 'My Page wall' I don't get anything. I don't get any errors either.
To access the posts of a page, it is /feed and not /post. Then, here is the correct version of your example :
require "facebook.php";
$facebook = new Facebook(array(
'appId' => YOUR_APP_ID,
'secret' => YOUR_APP_SECRET,
));
$pageFeed = $facebook->api(THE_PAGE_ID . '/feed');
Then the array $pageFeed will contain the 25 latest posts and links to navigation :
Array(
[data] => Array(
[0] => Array(
[id] => ...
[from] => ...
[to] => ...
[message] => ...
[icon] => ...
[type] => ...
[application] => ...
[created_time] => ...
[updated_time] => ...
)
[1] => ...
[2] => ...
...
[24] => ...
)
[paging] => Array(
[previous] => https://...
[next] => https://...
)
)
Hope that helps !
I know this is old, but I'll bring it up again! I just spent the last three days busting tail and trying to hack and crack the PHP SDK and Graph API, and I've done alright! I posted a full length lab with code and descriptions on my page, and you can view it below and ask me any questions you might have.
Basically, page feed is in a "graph" of info, or a super array. You use the app to connect to the facebook page, and get the feed. Connecting to a page's feed requires no permission from the page, hence why all you need is your APP ID, APP SECRET, and PAGE ID. The SDK automatically generates the APP ACCESS TOKEN for you, so you'r good there.
From then on, it's just about manipulating the graph. I've learned that Facebook feed has different types of posts. some are "photo", "message", "link". Anyways, check out the lab and tell me what you think.
http://www.callmenick.com/labs/displaying-a-custom-facebook-page-feed