facebook api post to wall - php

I currently am able to post to a users wall however I would like the post to give a preview since what im posting is a link...
To explain myself better If i was to log into my facebook account and copy a link and paste it to my wall it displays an audio player (all the meta data is already configured, tested and working) however, using code to post this same link it doesnt show the audio player instead it only shows the link to click on. Is there a way i can make facebook display the audio player...?
Heres the code im using to post:
$fbResult = $facebook->api(
'/' . $userId . '/feed/',
'post',
array('access_token' => $access_token, 'message' => $url)
);
Thanks in advance for the help!

I’m assuming you’re posting the URL as part of your message parameter?
Do it by explicitly using the link parameter for the URL.
https://developers.facebook.com/docs/reference/api/user/#links

Related

Set Event picture with Graph API with PHP SDK

I'm trying to figure this out all day...
With PHP SDK I can add a Facebook event to my Facebook page. But, if I try to set the wall picture of the events page, it isn't working. I found this:
/* make the API call */
$response = $facebook->api(
"/{event-id}/picture",
"POST",
array (
'source' => '{image-data}',
)
);
/* handle the result */
But the image-data has to be in multipart/form-data format. Does anyone know how to do this?
Also, I found that you could do this with a 'url' parameter instead of the 'source' parameter, but this isn't working either.
Maybe I've missed some permissions in my app settings?
Hope someone can help! Thanks!
I think you are talking of the event page's cover photo. You've used the method described in the official documentation to upload a cover photo of an event - but unfortunately this don't work as of now.
I've asked this before in the developers site, check here.
The only way to do this (as of now)-
\POST /{event-id} with param: cover_url
Code:
$param = array(
'cover_url' => '{image-link}'
);
$facebook->api('/{event-id}', 'POST', $param);
(image data wont work, you require a link to image)

Facebook Graph API PHP to make a comment to a post on a page as page

I'm using below code to post to my facebook page as page
$post_id = $facebook->api("/$page_id/feed","post",$args);
I want to make a comment to the post I created. I don't know how to do that exactly. But based on some research, I tried below code and it didn't work.
$comment_id = $facebook->api("/$post_id/comments?message='This is m message'");
An echo or print_r for $comment_id doesn't return anything.
How can I accomplish it i.e. posting comment to a post on my Facebook page using Facebook graph API for PHP? Kindly guide me in the right direction.
Try something like this,
$facebook ->api('/'.$post_id.'/comments',
'post',
array(
'access_token' => $your_access_token_variable,
'message' => 'Your message',
)
);

Is it possible to post a photo to Facebook by a link, not upload?

Is this possible to create a photo on user/page's timeline not by uploading said photo, but by providing a URL to an already uploaded image? My code so far is this:
$response = $fb->api ("/$page_id/photos", 'post', array (
'name' => $_description,
'source' => $_image_path
));
This results in OAuthException #324 "Requires upload file". Also, I'd like to photo to be immediately posted on the page's timeline - will it happen, or do I need to make a separate call for that?
You can switch parameter source for url, and give it a publicly reachable HTTP URL as value.
But be aware, this only works for photos not on Facebook already – feeding it the URL of a photo on Facebook will result in an error message saying that posting photos from their CDN is not possible.

Post image to Facebook fan page with PHP SDK

I am trying to upload a image to my fan pages wall using the PHP SDK, and also let other people upload pics to the page.
Here is what I have thus far,
PHP:
$img = realpath($y);
$facebook->setFileUploadSupport("http://" . $_SERVER['SERVER_NAME']);
$photo = $facebook->api('/FAN_PAGE_ALBUM_ID/photos', 'POST',
array(
'access_token' => $token,
'source' => '#' . $img,
'message' => 'This photo came from my app.'
)
);
When I try that nothing happens, even though I used a similar method to post to the fan pages wall, which worked fine, I also have the appropriate permissions, as far as I know... status_update,publish_stream,user_photos,offline_access ??
Any reason why this could be happening?
For you to be able to upload pictures to a page you are an administrator of, you would most likely need manage_pages permissions. I'm not sure you can have users upload pictures to a fan page from the graph api, although they can from the website so they should be able to.
You need this permission: manage_pages.

Facebook Photo Upload into Album on Fan Page failed

I have written an Application what posts Photos on a FanPage into a Specific Album long time ago.
Now I didn't used for a half year. Now I had to set up the Application again and grant the extended Permissions to the Fan Page (streamm_publish) again.
But now I've a Problem, I'm using the old REST API what now gives me the error: An unknown error ocurred with the error code 1.
Then I tried to post throught the Facebook Graph api.
I tried to make a call to the Api /pageid/albumid/photos what's not working(Unknown path components)
I tried to makea a call to /albumid_from_my_page/photos then the Photos were posted to my profile
I tried to upload it to /pageid/photos what is the same as the one above
But the code fpr the REST Api worked well, what's the problem there, and why the new Graph Api isn't working how she should?(BUG?)
To post a photo to an album, this is the code:
$post_data = array(
"message" => "My photo caption",
"source" => '#' . realpath($file)
);
$album_id = "XXXXX";
$facebook->api("/$album_id/photos", 'post', $post_data);
Now I suppose to interact with the page albums you need a page access_token added to your $post_data array, for this check this answer.
You need take ACCESS_TOKEN page...
try:
http://graph.facebook.com/me/accounts?access_token= GET THIS TOKEN USING GRAPH API... OR MAKE USING the getAccessToken()...
and will see all pages and aplications that u have, find just application for this case and COPY TOKEN... and damn!!!
It's possible to see this token thought GRAPH API EXPLORER...
regards.

Categories