Is there any way to change the Facebook album privacy settings with graph api?
I'm trying to find out, but all I could found is how to get the privacy settings using fql, but not to set.
I'm creating the album as follow
$postdata = http_build_query(array(
'name' => $album_name,
'message' => $album_description
)
);
$opts = array('http' =>
array(
'method'=> 'POST',
'header'=>
'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
) $context = stream_context_create($opts);
$result = json_decode(file_get_contents($graph_url, false, $context));
$albumid = $result->id;
Now if I add privacy=>"value", it gives $albumid=null.
I'm not sure where I need to add privacy parameter.
When you create an album, you can send these parameters in post request.
name, message, location and privacy.
Value of privacy field can be set like this,
privacy={value: "CUSTOM"} (send this as post parameter)
The value field may specify one of the following strings:
EVERYONE, ALL_FRIENDS, NETWORKS_FRIENDS, FRIENDS_OF_FRIENDS, CUSTOM .
As facebook docs sucks, there's no mention about it on albums object page.
However, you can read it on post object.
Edit: (after comments)
In php sdk you can do something like this,
$ret_obj = $facebook->api('me/albums', 'POST',
array(
'privacy' => '{value: "CUSTOM"}',
'location' => 'India'
));
The document of creating an album is put in https://developers.facebook.com/docs/reference/api/user/#albums
Privacy setting is a json-style string. So you could create an array() and use json_encode() to generate it.
with php sdk it is also possible as php style #kaur
$ret_obj = $facebook->api('/me/albums/', 'POST', array(
'source' => '#' . $photo,
'message' => 'Picture uploaded',
'location' => 'Goran',
'privacy'=> array('value'=>'EVERYONE'), //'privacy'=> '{value: "EVERYONE"}', //worked too!! SELF, ALL_FRIENDS, EVERYONE
)
);
Related
I am trying to use the Graph API to post on the wall of the authenticated user.
The issue which I am facing is when I try to share a post e.g.
http://www.facebook.com/surendrakumar.in/posts/486644641373819
using Graph API to the users feed
$story_url = "http://www.facebook.com/surendrakumar.in/posts/486644641373819"
$ret_obj = $facebook->api('/me/feed', 'POST',
array(
'access_token' => $fb_access_token,
'link' => $story_url,
'message' => ($msg != "" ? $msg : "")
));
Then the post which is getting shared in the Facebook is only a link, which is not expected.
Expected :
Post on the wall with http://www.facebook.com/surendrakumar.in/posts/486644641373819 link and details of the post, preview etc.
Actual:
Only a link is posted. no preview, and any other information.
Put the link within the message text.
I.E.:
$story_url = "http://www.facebook.com/surendrakumar.in/posts/486644641373819"
$ret_obj = $facebook->api('/me/feed', 'POST',
array(
'access_token' => $fb_access_token,
'message' => ($msg != "" ? $msg."\n".$story_url : "".$story_url)
));
At this moment "like" button works just with facebook groups. I want to implement "like" button to my website and let people to like photos of my site. It is possible to do it? Or how to programically like facebook photos?
You can like any object, including a photo object by issuing a post to its object url, after receiving proper permissions " publish_stream". Deleting the like is same, just issue 'delete' instead of 'post'
https://developers.facebook.com/docs/reference/api/photo/#likes
Using php sdk 3.1.1, with user access token you can :
-----publish like----- this will post a like to the photos like object.
<?php
$params = array(
'access_token' => ''.$access_token.'',
'method' => 'post'
);
$pageLike = $facebook->api('/PhotoID/likes', 'post', $params);
?>
-----issue delete----- this will delete a like to the photos like object.
<?php
$params = array(
'access_token' => ''.$access_token.'',
'method' => 'post'
);
$pageLike = $facebook->api('/PhotoID/likes', 'delete', $params);
?>
I use below code to post an url to facebook page as a admin but if i post an message,it is posting but it is not posting photos and url.
$args = array(
'access_token' => token,
'message' => $url
);
$wall = $facebook->api("/".$pid."/feed","post",$args);
Is there any other function that does that?
You need to add
'caption'
'link'
'picture'
variables to your array to show a picture with a caption and a link to a url.
Right now I'm trying to figure out how to post an attachment using facebooks graph api.
Right now I'm using
$attachment = array(
'message' => $_POST['tt'],
'text' => 'Download',
'name' => 'name',
'href' => 'http://www.url.com',
'description' => ' description!',
'media' => array(array(
'type' => 'mp3',
'src' => $url,
'href' => 'http://www.url.com/',
'title' => $title,
'artist'=> 'artist',
'album'=> 'the album')));
$statusUpdate = $facebook->api('/me/feed', 'post', $attachment);
Problem is it's only posting the message, nothing else, no attachment or anything.
Does anyone have any idea why?
Thanks
Attachments aren't yet supported by the Graph API.
Per the documentation
Arguments message, picture, link,
name, caption, description, source
See my answer in your other question for a workaround.
You have to use the old php SDK until graph supports attachments... Graph only supports photoupload.
Im mixing Graph and old SDK without problems..
I'm using the old Rest API (and old Javascript SDK) to develop an iframe application inside facebook.
However I would like to have the wall posts (calling stream.Publish) to include new lines and having people's names with links to their profiles. However every time I include html content, FB strips it.. but I know it can be done, because some apps do it, for example:
http://img.skitch.com/20100702-jhqradpi3td4d53sdb3qin92sb.png
Cheers,
Ze
You cannot have arbitrary HTML in a wall post. If it looks like HTML, Facebook will strip it. The only other alteration Facebook will do I believe is convert text that looks like links into links (so if you have http://www.google.com somewhere in the message, Facebook will automatically turn it into a link).
However Facebook does provide basic facilities for including basic things like a picture, caption, description, link, etc through stream.publish by passing in additional parameters. This is an example for including a few of these things from Facebook's documentation (http://wiki.developers.facebook.com/index.php/Stream.publish):
$message = 'Check out this cute pic.';
$attachment = array(
'name' => 'i\'m bursting with joy',
'href' => 'http://icanhascheezburger.com/2009/04/22/funny-pictures-bursting-with-joy/',
'caption' => '{*actor*} rated the lolcat 5 stars',
'description' => 'a funny looking cat',
'properties' => array('category' => array(
'text' => 'humor',
'href' => 'http://www.icanhascheezburger.com/category/humor'),
'ratings' => '5 stars'),
'media' => array(array('type' => 'image',
'src' => 'http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg',
'href' => 'http://icanhascheezburger.com/2009/04/22/funny-pictures-bursting-with-joy/')),
'latitude' => '41.4', //Let's add some custom metadata in the form of key/value pairs
'longitude' => '2.19');
$action_links = array(
array('text' => 'Recaption this',
'href' => 'http://mine.icanhascheezburger.com/default.aspx?tiid=1192742&recap=1#step2'));
$attachment = json_encode($attachment);
$action_links = json_encode($action_links);
$facebook->api_client->stream_publish($message, $attachment, $action_links);
Check this out for more info on what attachments you can include.