Postear en un Fanpage usando PHP o JavaScript
$30-250 USD
Publicado hace casi 10 años
$30-250 USD
Pagado a la entrega
Hay que desarrollar o ayudar a desarrollar una funcion en php o una pequeña pagina que dado un codigo de una publicación de un comentario en un fan page, de respuesta a el.
Tenemos el siguiente código hasta ahora pero aplicación responde que no hay autorización.
<?php
$fbId = '231705796841829';
// Valid access token, I used app token here but you might want to use a user token .. up to you
$app_id = "xxxx";
$app_secret = "xxxx";
$post_id = "xxxx";
$redirect_uri = "[login to view URL]";
$accessToken = $app_id.'|'.$app_secret;
$code_url = '[login to view URL]' . $app_id . '&redirect_uri=' . urlencode($redirect_uri) . '&scope=publish_stream';
$post_login_url = $redirect_uri;
$code = $_REQUEST["code"];
//Obtain the access_token with publish_stream permission
if(empty($code)){
$dialog_url= "[login to view URL]"
. "client_id=" . $app_id
. "&redirect_uri=" . urlencode( $post_login_url)
. "&scope=publish_stream";
echo("<script>top.location.href='" . $dialog_url
. "'</script>");
}
else {
/*
$token_url="[login to view URL]"
. "client_id=" . $app_id
. "&redirect_uri=" . urlencode( $post_login_url)
. "&client_secret=" . $app_secret
. "&code=" . $code;
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$access_token = $params['access_token'];
*/
// "[login to view URL]"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$code_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt($ch, CURLOPT_HEADER ,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
$fb_code = curl_exec($ch); // get code
curl_close($ch);
$url = '[login to view URL]' . $fbId . '/feed';
$attachment = array(
'access_token' => $accessToken,
'message' => "Hi",
);
$go = json_decode($go, TRUE);
if( isset($post_id) ) {
$url = "[login to view URL]".$post_id."/comments";
$attachment = array(
'access_token' => $accessToken,
'message' => "Hi comment",
);
// set the target url
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$comment = curl_exec($ch);
curl_close ($ch);
$comment = json_decode($comment, TRUE);
print_r($comment);
}
}
?>
ID del proyecto: 5918164
Información sobre el proyecto
Proyecto remoto
Activo hace 10 años
¿Buscas ganar dinero?
Beneficios de presentar ofertas en Freelancer
Fija tu plazo y presupuesto
Es gratis registrarse y presentar ofertas en los trabajos