Using 'from' to post a facebook message as App name - facebook

I have an Facebook App that is currently posting to a WALL. All the posting are being Titled as MY post. I would like it to be titled by the App. In this documentation, it says there is a 'from' parameter. I've tried to use it a couple of ways and both ways have been unsuccessful. Does anyone have a clue?
https://developers.facebook.com/docs/reference/dialogs/feed/
$attachment = array('message' => $message,
'from' => "<APP_ID>",
//'from' => array('name' => "Sender's Name",'id' => "<APP_ID>"),
}
$me = $this->facebook->api('/me/feed/', 'POST', $attachment);

The from property MUST be a user or a page. You could possibly create a Facebook page with the name of your application and use that.

I've never used the FROM parameter in the Graph API, just on the legacy REST API. And that API parameter was actually actor_id instead of FROM.
Obviously this doesn't solve your problem. To solve your problem, get the access_token for your page from the /me/accounts Graph API end point. When you use this access token, you are identified as the account for which it corresponds, and when you post to /{page_id}/feed with it, it will be posted as the page and in turn be published out to all your users.
<script type="text/javascript">
FB.api("/123123123/feed", "post", {
message: "Test!",
access_token: '184484190795|SDlfkjweifljasdf.3600.123123123.1-2342342|234234234234|XLjsldfjLISJflwieab'
},
function(response)
{
console.log(response);
});
</script>

Thank you all for the suggestions. I finally was able to solve the problem by combining these 2 articles. The basic steps of the first article is still valid. But it is written in the old API. The second article help be get through the step the new REST api couldn't do. Hope this helps.
http://www.emcro.com/blog/2009/01/facebook-infinite-session-keys-no-more/
http://www.alyssapowell.com/2010/10/how-to-generate-an-infinite-session-key-in-facebook/

Related

Facebook timeline wallpost doesn't work as aspected

Im using the Facebook SDK Api [PHP] to post automaticly on a timeline wall.
I created a App and requested the access_token with the following permissions: manage_pages,publish_stream,offline_access.
Im using now the access_token to post the message on a page (/PAGEID/feed) where im moderator.
The following is going OKAY and get the post working under the name of the Facebook page:
$attachment = array(
'access_token' => $accessToken,
'message' => $description,
);
$res = $facebook->api('/PAGEID/feed', 'POST', $attachment);
When Im adding some link + name AND/OR picture it will post not as wall post but as "recent message of others" with as name my own user:
$attachment = array(
'access_token' => $accessToken,
'message' => $description,
'link' => 'http://www.google.nl',
'name' => $description,
'picture' => $image,
);
How can I post full messages with link and picture on the wall self?
If I understand you correctly, you are trying to post as the Page but it's showing up as a post by you. Is that correct?
If so, I think you need to post using the Page's access token, rather than your own access token. Look at the section called "Page Access Tokens" on https://developers.facebook.com/docs/reference/api/page/. Once you get the page's access token using the technique described there, you can set it to be the token that PHP SDK uses by doing $facebook->setAccessToken(.... access token value ...). Then you can do the post and it should show up as having been created by the page.
This problem troubled me for so long. Everything seemed setup correctly but as soon as I added a link, it would post as Admin instead of Page. The answer above by triangle_man solved my problem. When using the PHP sdk, the specific line of code I needed was:
$page_token = $facebook->api("/$page_id?fields=access_token");

Facebook Graph API Group Files

Facebook offers a new functionality for groups. Now it is possible to post also files within a group. (http://mashable.com/2012/05/10/facebook-groups-3/)
I am trying to query now the files using the Graph API but on the documentation site there are only 4 urls described. "docs", "members", "feed", "picture".
When I read the "feed" path I will not get file postings.
Is there a hidden path? I also found no new permission.
Anyone has any idea?
I have searched for a solution on several internet pages but there are only descriptions on how to read and post photos, which is described in the document.
Is there nobody writing an app where you can upload files to groups?
try this, this might be helpful for you
try {
$facebook->api('/'.$groups[$id].'/feed', 'POST',
array(
'access_token' => $access_token,
'message' => stripslashes(stripslashes($mapp_message)),
'name' => stripslashes($name),
'link' => $link,
'description' => stripslashes(stripslashes($description)),
'picture' => "images/send_imges/".$image
)
);
} catch(FacebookApiException $e) {
echo $e;
}
The Graph API documentation for Groups mentions a way to retrieve the documents from a group. If you click the docs connection in the document, it'll take you to the Graph API Explorer, where you can test your sample queries. So, basically, all you need to do to obtain the document uploaded to a group is perform a request to the following url with a valid Access Token (with no special permission):
https://graph.facebook.com/groupId/docs
Or, if you want to access a specific doc, you need the document_id for that particular doc. So you can simply request the following URL with a valid Access Token:
https://graph.facebook.com/docsId
The instructions on posting a doc and its related permissions have been discussed in this answer. I'm not very sure whether it works or not as I have not tested the method. But I'm pretty sure that you can read the details by making an API call to the urls mentioned above.

PHP Facebook wallpost tracking

I have such code to post on my friends wall from application
$args = array(
‘message’ => 'my message',
‘name’ => ‘This is my demo Facebook application!’,
‘caption’ => “Caption of the Post”,
‘link’ => $data['view_url'],
‘description’ => ‘this is a description’,
‘picture’ => $body_all["thumb"],
‘actions’ => array(array(‘name’ => ‘View’,
‘link’ => $data['view_url']))
);
$post_id = $facebook->api(“/”.user_$id.”/feed”, “post”, $args);
In array $post_id['id'] facebook returned me id of the post(like that: 100003284224348_121820851270722), and then when i wona to track it, and get some info by ID, i ask FBgraph https://graph.facebook.com/$post_id['id'] but its return false… i have publish_permission, read_streem permission in my application… what i do wrong? why i couldn`t see post in info with id on Facebook graph?
If the graph API GET request is returning false this is usually a tell tell sign that there is an access token issue at the heart of the problem. When you are making the GET request ensure you are using your applications access token.
Try it here: http://developers.facebook.com/tools/explorer/?method=GET&path=100003284224348_121820851270722
It could be a timing issue, where you get back the ID and try to use it before facebook's API can see it. Try waiting a moment and checking. Does it come up in the graph API explorer tool?

How can I post new comment with Graph API into Social Comments Box?

I have facebook social comments box. How can I post comment through graph API to it?
I can give you half the answer to this question, but still need the other half very much myself. You can post a reply to an existing comment within Social Comments box by finding its post_fbid. To get this you can use FQL such as:
https://api.facebook.com/method/fql.query?query=SELECT post_fbid, id FROM comment WHERE object_id IN (SELECT comments_fbid FROM link_stat WHERE url ='[ PAGE_URL ]')&access_token=[ ACCESS_TOKEN ]
This query will need to be run through an escape() with the PAGE_URL and then used for an HTTP GET request:
https://api.facebook.com/method/fql.query?query=SELECT%20post_fbid%2C%20id%20%0A%20%20%20%20%20%20%20%20FROM%20comment%20%0A%20%20%20%20%20%20%20%20WHERE%20object_id%20IN%20%0A%20%20%20%20%20%20%20%20%20%20(SELECT%20comments_fbid%20%0A%20%20%20%20%20%20%20%20%20%20%20FROM%20link_stat%20%0A%20%20%20%20%20%20%20%20%20%20%20WHERE%20url%20%3D'http%3A%2F%2Fexample.com')&access_token=[ ACCESS_TOKEN ]
With the post_fbid you can make a reply by doing an HTTP POST to:
https://graph.facebook.com/[ POST_FBID ]/comments/?access_token=[ ACCESS_TOKEN ]&message=[ MESSAGE]
Now for posting a new comment to the page this used to work until recently with an HTTP POST:
http://graph.facebook.com/comments/?ids=[ PAGE_URL ]&access_token=[ ACCESS_TOKEN ]&message=[ MESSAGE]
But currently this is consistently returning:
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException"
}
}
I hope this helps a bit and if anyone can shed some light if posting a new comment like this is even possible anymore it would be greatly appreciated.
Seems that it is not possible, and will never be:
This functionality was never and is not intended to be available.
An error message has been added for this case: "Comments may not be
added to a comment plugin"
https://developers.facebook.com/bugs/164794086987157
Its very easy as you post on user feed after getting access_token with publish stream token
I assume you use PHP SDK if you need in other let me known
You just need Step 4 but i give you more details in Step 1 to 3 so you can understand and do clearly
Step 1
get the user access token
$token = $facebook->getAccessToken();
echo "</br>" . 'Access_Token:' . $token;
Step 2
set default access token and profile
$facebook->setAccessToken($token);
Step 3
compile the post
$WallPost = array(
'message' => 'hey this app is cool!!',
'link' => $canvas_page,
'caption' => 'caption',
'description' => 'Test Description',
); // you can also use 'picture', 'description', 'source'....
Step 4
post to wall or your Social Comment Plugin
$response = $facebook->api('/me' . '/feed','POST',$WallPost);
Thanks

How to Post with Application Name

I'm using the simple code to post on user's wall. This:
$postwall = $facebook->api("/".$id."/feed", 'post', array(
'message' => "test",
'link' => 'http://www.Google.com',
'name' => 'test.',
'description'=> 'test.'
));
This code works but, it's posting with mine facebook name. I want to post with the application name. I searched for authenticating with application name, i tried everything but finally i didn't resolve my problem. Is there anyone who can help me with this please ?
I don't think this is possible. I guess this is the error you'll get:
(#200) Posts where the actor is a page
cannot also include a target_id
What I've done here is that getting the manage_pages permission and then get the application (profile page) access_token and tried to append it to the POST call.