Hallo,
Ik heb een raar probleem.
Als ik de foto naam direct in de PHP code schrijf dan werkt de upload prima.
Maar als ik de naam via $_GET aan de string toevoeg dan werkt het niet.
De uitvoer in HTML ziet er het zelfde uit. Maar de upload naar facebook werkt niet?
Aanroep: www.website.n//event1/upload?photo=123456.jpg
De Code die werkt:
[php]$photo_url = “http://website.nl/event1/pictures/123456.jpg”;
[/PHP]
En deze photoName via $_GET dus niet
[PHP]
$photo_url = “http://website.nl/event1/pictures/” .photoName;
[/php]
[php]
<?php
$photoName = '';
//check what photo we are looking for
if(isset($_GET['photo'])){
$photoName = $_GET['photo'];
}
?>
<?php
$app_id = "**************";
$app_secret = "#############";
//Take NOTE: this must include http://
//ex. http://sharefavoritebibleverses.com/fb_connect.php
$post_login_url = "http://website.nl/event1/upload.php";
//Take NOTE: this must include http://
$photo_url = "http://website.nl/event1/pictures/123456.jpg";
//you can add link to your image caption, but you can't use this tag
visit my link
$photo_caption = "Voor meer foto's kijk op http://website.nl/event1";
$code = $_REQUEST["code"];
//Obtain the access_token with publish_stream permission
if (!$code)
{
$dialog_url= "http://www.facebook.com/dialog/oauth?"
. "client_id=" . $app_id
. "&redirect_uri=" . urlencode( $post_login_url)
. "&scope=publish_stream";
echo("");
}
else
{
$token_url="https://graph.facebook.com/oauth/access_token?"
. "client_id=" . $app_id
. "&client_secret=" . $app_secret
. "&redirect_uri=" . urlencode( $post_login_url)
. "&code=" . $code;
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$access_token = $params['access_token'];
// POST to Graph API endpoint to upload photos
$graph_url= "https://graph.facebook.com/me/photos?"
. "url=" . urlencode($photo_url)
. "&message=" . urlencode($photo_caption)
. "&method=POST"
. "&access_token=" .$access_token;
echo '';
//echo file_get_contents($graph_url);
$ok = file_get_contents($graph_url);
if($ok)
echo'';
echo '';
}
?>
[/php]
En de code die niet werkt:
[php]
<?php
$photoName = '';
//check what photo we are looking for
if(isset($_GET['photo'])){
$photoName = $_GET['photo'];
}
?>
<?php
$app_id = "**************";
$app_secret = "#############";
//Take NOTE: this must include http://
//ex. http://sharefavoritebibleverses.com/fb_connect.php
$post_login_url = "http://website.nl/event1/upload.php";
//Take NOTE: this must include http://
$photo_url = "http://website.nl/event1/" .$photoName;
//you can add link to your image caption, but you can't use this tag
visit my link
$photo_caption = "Voor meer foto's kijk op http://website.nl/event1";
$code = $_REQUEST["code"];
//Obtain the access_token with publish_stream permission
if (!$code)
{
$dialog_url= "http://www.facebook.com/dialog/oauth?"
. "client_id=" . $app_id
. "&redirect_uri=" . urlencode( $post_login_url)
. "&scope=publish_stream";
echo("");
}
else
{
$token_url="https://graph.facebook.com/oauth/access_token?"
. "client_id=" . $app_id
. "&client_secret=" . $app_secret
. "&redirect_uri=" . urlencode( $post_login_url)
. "&code=" . $code;
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$access_token = $params['access_token'];
// POST to Graph API endpoint to upload photos
$graph_url= "https://graph.facebook.com/me/photos?"
. "url=" . urlencode($photo_url)
. "&message=" . urlencode($photo_caption)
. "&method=POST"
. "&access_token=" .$access_token;
echo '';
//echo file_get_contents($graph_url);
$ok = file_get_contents($graph_url);
if($ok)
echo'';
echo '';
}
?>
[/php]
Iemand idee?
Thanks