Jump to content

CURL / Facebook graph api help


frobak

Recommended Posts

Hi

 

Im trying to post to the graph api using curl. This script already obtains access tokens etc.

 

I've managed to post a feed item using this, so this works fine

 

	if($_POST['txt']){
	//if there is a posted data, then post it in facebook
	$params = array('access_token'=>$_SESSION['accesstoken'], 'message'=>$_POST['txt'] );
	$url = 'https://graph.facebook.com/255500227799817/feed';

	$ch = curl_init();
	curl_setopt_array($ch, array(
	CURLOPT_URL => $url,
	CURLOPT_POSTFIELDS => $params,
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_SSL_VERIFYPEER => false,
	CURLOPT_VERBOSE => true
	));
	$result = curl_exec($ch);
	curl_close($ch);

}

 

But i cant post a comment on the feed item using this, but surely it should work the same? The documentation says so? 

 

	if($_POST['new-comment']){

	$fb_post_id = $_POST['new-fb-post-id'];
	$fb_new_comment = $_POST['new-comment'];

	//if there is a posted data, then post it in facebook
	$params = array('access_token'=>$_SESSION['accesstoken'], 'message'=>$_POST['new_comment']);
	$url = 'https://graph.facebook.com/'.$fb_post_id.'/comments';

	$ch = curl_init();
	curl_setopt_array($ch, array(
	CURLOPT_URL => $url,
	CURLOPT_POSTFIELDS => $params,
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_SSL_VERIFYPEER => false,
	CURLOPT_VERBOSE => true
	));
	$result = curl_exec($ch);
	curl_close($ch);

}

 

Any thoughts?

 

cheers

Link to comment
https://forums.phpfreaks.com/topic/242216-curl-facebook-graph-api-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.