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?
Related
I am currently working on Moodle and i am trying to upload an image and display it.
I followed all the steps explained here : https://docs.moodle.org/dev/Using_the_File_API_in_Moodle_forms#Simple_use
and it is working.
For example if i upload a file with some text in it and i access the URL given by the make_pluginfile_url function it will display the text that is inside the file.
The problem is when i upload an image it doesn't display the image but some text like this :
(+�ء��\U�k���*�j~�Uܽ�U���W\Uت�k��zb��S�
I suppose it's because the File API treats the image as a text file and not as an .jpg.
Could someone tell me how i could make it display the image ?
Display it with html_writer class. Example:
html_writer::empty_tag('img', array('src'=> $url));
Where $url is valid url to your file. (Prepared with moodle_url::make_pluginfile_url() or similar)
empty_tag docs
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 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"];
I'm trying to get the download source from a Google Drive file I own. I currently have this code:
$videoSRC = "https://www.googleapis.com/drive/v3/files/". $_GET['id']. "?alt=media&key=API_KEY_HERE";
echo '<video autoplay="" preload="auto" src="'. $videoSRC. '"></video>';
The problem is, when you look at the video source, it says the video source is "https://www.googleapis.com/drive/v3/files/GOOGLE_FILE_ID?alt=media&key=API_KEY_HERE". While it does display the video, I've seen that website have their video source as "https://redirector.googlevideo.com/videoplayback". How are they able to achieve this?
I suggest using the webContentLink of the file which is generated by using the Files.get.
Files.get uses the following URI request:
https://www.googleapis.com/drive/v3/files/fileId
Tried this on one of my file and got this webContentLink:
https://docs.google.com/uc?id=0Bzgk4zccNwI7MmJOYWs3SG1VUUE&export=download
You can pass this link in your GET request in PHP and see if it downloads the file.
I have an image thumbnail, encoded as base64, that I want to use as the default thumbnail when sharing a page via Facebook. Facebook does not seem to support using the base64 image directly so I need to render/save/decode(?) it first before the user can click the "share" button. Any thoughts?
Here's my thumbnail:
$thumbnail = '<img src="data:image/jpg;base64,' . $thumbnail_src . '" />';
Obviously it renders fine in the browser but Facebook can't "get it."
Try looking at the GD Library first. And then create a php page that will render the image with the correct header so Facebook will see this as an image.
I ended up decoding the image and writing it to a temporary directory.