Cancelado

Postear en un Fanpage usando PHP o JavaScript

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 = "[url removed, login to view]";

$accessToken = $app_id.'|'.$app_secret;

$code_url = '[url removed, login to view]' . $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= "[url removed, login to view]"

. "client_id=" . $app_id

. "&redirect_uri=" . urlencode( $post_login_url)

. "&scope=publish_stream";

echo("<script>top.location.href='" . $dialog_url

. "'</script>");

}

else {

/*

$token_url="[url removed, login to view]"

. "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'];

*/

// "[url removed, login to view]"

$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 = '[url removed, login to view]' . $fbId . '/feed';

$attachment = array(

'access_token' => $accessToken,

'message' => "Hi",

);

$go = json_decode($go, TRUE);

if( isset($post_id) ) {

$url = "[url removed, login to view]".$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);

}

}

?>

Habilidades: HTML, Javascript, PHP

Ver más: un code, php script null, go to top javascript, get location javascript, array graph, php html javascript, pagina facebook, ayudar, script facebook token, access token script, facebook token script, javascript array com, fbid com, javascript comment, javascript null, php permission, json_decode, php facebook access token, oauth javascript, php user permission

Información del empleador:
( 0 comentarios ) Suiza, Mexico

Nº del proyecto: #5918164