I'm trying to post images on wall when choosing it, i'm working with PHP SDK,
So images are fine when using the absolute path of the image like ( "C://...")
But i want to post online image under a server like ( "http:mywebsite.com/image.jpg" )
the URL is like : localhost/facebook/image.jpg , i tried also another image combiboilersleeds.com/images/online/online-0.jpg
I tried it but it doesn't work I'm getting error :
CurlException: 26: couldn't open file ""
What should i do ?
I'm using the code below :
$image['image'] = '#'. $data["path"];
$facebook->setFileUploadSupport(true);
$img = $facebook->api('/me/photos', 'POST', $image);
$data is the array in which i conserve images absolute paths.
Got it , I supposed to use $image['url'] = ' MyURL' for uploading an url instead of $image['image'] = '#'. $data["path"];
Related
This is the url: https://scontent.xx.fbcdn.net/v/t34.0-12/15749870_10153984148031541_865898377_n.jpg?_nc_ad=z-m&oh=73dc146bd7d8922a41c262ecc2299bb4&oe=58659947
I want to save Facebook images to my server. I tried many options such as copy, file_get_contents etc. What happens is that i get a blank image file that has 0 file size.
How do i save/copy facebook image url to my server as an image?
Try:
$url = "https://scontent.xx.fbcdn.net/v/t34.0-12/15749870_10153984148031541_865898377_n.jpg?_nc_ad=z-m&oh=73dc146bd7d8922a41c262ecc2299bb4&oe=58659947";
$img = './your_image_name.jpg';
file_put_contents($img, file_get_contents($url));
I'm working with BLOB image in PHP. My images has no absulut url ( like this : www.example.com/my_image) . I need it because i'm woking with facebook open graph image sharing. How can i fix that?
i am trying to save a video thumbnail from dailymotion i can bring the image URL but the actual problem i am getting is to save that thumbnail on my server by renaming image. Secondly i want to check that name if the name is already exist on the server it can replace the older one this function is basically used on updating video id.
Here is my php code to grab dailymotion video thumbnail url but i don't know to to save it
<?php
$related_dm_code = "x2rxn6i"; //Video Code
$thumbd_item='https://api.dailymotion.com/video/'.$related_dm_code.'?fields=thumbnail_240_url';
$json_thumbnail2_item = file_get_contents($thumbd_item);
$get_thumbnail2_item = json_decode($json_thumbnail2_item, TRUE);
$thumb2_item=$get_thumbnail2_item['thumbnail_240_url'];
echo $thumb2_item; //display thumbnail url
?>
e.g. here is the thumbnail url:
anothersite.com/images/demo-image.jpg
How can i save image in this path of my URL:
mysite.com/video_thumbs/
and renaming demo-image.jpg to anyothername.jpg
and then a last part of the function to check and replace if anyothername.jpg is already exist then replace with the older one this would be used to updating mysql
You mean something like:
if (!file_exists('http://www.example.com/video_thumbs/' . $file)) {
$img = file_get_contents("http://www.anothersite.com/images/demo-image.jpg");
file_put_contents('http://www.example.com/video_thumbs/' . $file, $img);
}
I have this code that has an image tag. The img src is equal to "https://graph.facebook.com/<?php echo $user_id; ?>/picture". Is there anyway that I could get that image file and upload it to my server using the move_uploaded_image function with php?
No, move_uploaded_image moves files that were uploaded in a POST request.
If you want to get an image from a URL you need to make an HTTP request for it, e.g. via cURL.
Using PHP's imagecreate and file_get_contents and file_put_contents, you can create a blank image, get the image from the remote URL, then replace the blank image you created.
Similar to,
// Create a blank image
$imPath = "path/to/your/desired/image.jpg";
$im = imagecreatetruecolor(180, 151);
imagejpeg($im,$imPath);
// Download their fb image
$url = 'https://graph.facebook.com/' . $user['username'] . '/picture?type=large';
$bytes = file_put_contents($imPath, file_get_contents($url));
there is no function like move_uploaded_image . correct function is move_uploaded_file.
no. you can not get image file by this function .
first argument of this function is temp file name which is uploaded through Input type = file.
and another argument is the location where you want to put file....
you should refer $_FILES of php manual for more information....
http://php.net/manual/en/function.move-uploaded-file.php
How can I prepare a dynamic image created by GD for upload?
I created a php script to create dynamic images based on the userid (EX: www.mywebsite.com/image/124.png <== that should show the user 124 info)
Now I need to upload it to Facebook with this script :
$photo_details = array(
'message'=> $message
);
$file = "$_GET[id].png";
$photo_details['image'] = '#/home/username/public_html/image/' . $file;
$upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details);
When I use the upload script that way I get this error:
Fatal error: Uncaught CurlException: 26: failed creating formpost data
But If I uploaded 124.png to /image/ directory and and tried the same code again with using the ID 124 it works just fine. After a long research I came to conclusion the problem relay in the dynamic part since it works just fine with static images. How can I solve this problem?
Thank you so much for all the help.
Looks like the script tries to read the file directly from the filesystem instead of running the image generating script. You can solve this by setting $photo_details['image'] = 'http://www.mywebsite.com/image/'.$file; if Facebook class allows this kind of file opening.