I have a FB app that enable the user to draw shapes and type text on a canvas. The app should have a feature to share what is on canvas on FB as custom story. I was able to do that using PHP SDK.
My question is can I do the same using only JavaScript SDK without any server side code?
Thanks,
Haider
My PHP code is below:
$imgDataBase64 = $_REQUEST["imgBase64"];
$img = str_replace('data:image/png;base64,', '', $imgDataBase64);
$img = str_replace(' ', '+', $img);
$imgData = base64_decode($img);
$pictName = tempnam(sys_get_temp_dir(),"hs").".png";
$ret = file_put_contents($pictName, $imgData);
if ($fbuser) {
try {
$access_token = $facebook->getAccessToken();
$imageURI = $facebook->api(
'me/staging_resources',
'POST',
array(
'file' => "@".$pictName.";type=image/png",
'access_token' => $access_token
)
);
$object = $facebook->api(
'me/objects/testapp:photo',
'POST',
array(
'access_token' => $access_token,
'object' => array(
'app_id' => xxxxxxxxxxxxxxx,
'type' => "testapp:photo",
'title' => "test",
'image' => array (
'url' => $imageURI['uri'],
'user_generated' => true
)
)
)
);
$action = $facebook->api(
'me/testapp:share',
'POST',
array(
'photo' => $object['id'],
'access_token' => $access_token
)
);