I have created a Facebook App to upload photos to facebook from image url with help of some tutorials. It needs an image url and description. I want to put a button "Upload to Facebook" below every "Image" type posts in wordpress.
App Main Part to upload images -
<?php
if(isset($_POST["source"]))
{
try {
$access_token=$facebook->getAccessToken();
$graph_url= "https://graph.facebook.com/me/photos?"
. "url=" . urlencode($_POST["source"])
. "&message=" . urlencode($_POST['message'])
. "&method=POST"
. "&access_token=" .$access_token;
$response=file_get_contents($graph_url);
$json=json_decode($response);
}
catch (FacebookApiException $e) {
error_log('Could not post image to Facebook.');
}
}
?>
<form enctype="multipart/form-data" action=" " method="POST">
Paste an image URL here:
<input name="source" type="text"><br/><br/>
Say something about this photo:
<input name="message"
type="text" value=""><br/><br/>
<input type="submit" value="Upload" class="btn btn-primary"/><br/>
</form>
How can i extract image src dynamically from a custom post type(Image), and set src as source
in form automatically. (There is only one image in every image type post)
src
located?post_content
?get_post_meta
. I don't know, that's why i posted my query here.