I found noembed as a free alternative of embed.ly
But There is no DOCS for using its service.
Can anyone help me to use NoEmbed in PHP and getting the Thumb Link back from JSON return?
(I think This can be solved using CURL, but as I don't know too much about CURL, I am looking at you, No Curl:preferred)
file_get_contents() is what you are looking for.
This sample should be self-explanatory.
$json = file_get_contents('http://noembed.com/embed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE');
var_dump(json_decode($json)->thumbnail_url);
Related
i want to read a google spreadsheet over google spreadsheet api via XML.
I try different ways, e.g.
<?php
$data = file_get_contents("https://spreadsheets.google.com/feeds/worksheets/WORKSHEET_KEY/private/full");
?>
or
<?php
simplexml_load_file(URL)
?>
but i only give an emtpy string.
the document is public and if i surf on the site directly, it works.
Can you help me?
Have a look at the following article: http://arlando.net/blog/connecting-to-google-spreadsheet-api-with-php/
I would also recommend reading this documentation from google API's https://developers.google.com/google-apps/spreadsheets/
This is more than likely related to the following answered question:
Loading a remote xml page with file_get_contents()
Your server probably doesn't allow opening remote urls with file_get_contents.
The accepted answer on this page shows a workaround with curl
I'm trying very simple in PHP and not very sure what to search here or on google.
Problem is -
In PHP function I want to call/get a URL
http://www.example.com/message?Name=MyNameIsX
and like to read the return value (body) at this URL (which may contain "Your Name is MyNameIsX")
I tried
$data = file_get_contents($url)
This is timing out; although I'm able to open the $url in the browser.
Yes, file_get_contents normal use for files on this server and base on support and setting this perhaps is not allow.
See PHP CUrl http://php.net/manual/en/curl.examples.php or example
http://php.net/manual/en/curl.examples.php, http://php.net/manual/en/curl.examples-basic.php
You could use cUrl as suggested by FIG-GHD742 but I find the HTTP extension a lot easier to use. It's newer and has a neat OOP api.
Another method is that you can actually do an include/require with these, but it's generally a bad idea to do so if you don't control the source from which the data is coming
It sounds like you need to enable loopback calls on the server (self-calls). It would be better to get the data on the backend if you need it on the same server. Via a PHP API or calls to a database.
**
This will help you lot : http://php.net/manual/en/curl.examples.php
http://php.net/manual/en/curl.examples.php,
http://php.net/manual/en/curl.examples-basic.php
**
Yes the above answers is right. some hosting providers disable it for security purpose. You may also try fopen(php) if you are not looking for Curl way. Read documentation here http://php.net/manual/en/function.fopen.php
So I am trying to parse content from an infoboxe template in a wikipedia page. But I have to use PHP because I cannot configure my server alone and I haven't the permission to do that.
(So i cannot use the framework Dbpedia)
I need help because I am trying to understand how I can parse this object Infoboxe.
Example on this url : http://fr.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&rvsection=0&titles=Roger_Federer
Plz Don't tell me to look the documentation, it's boring and not very usefull.
I keep going trying to parse this content but I don't understand how I can do with PHP ?
THhhhhxxxx to help me !! :)))
You can call this python script using exec():
https://stackoverflow.com/a/9208881/956397
exec() manual: http://www.php.net/manual/en/function.exec.php
spent a few hours trying to figure this out, but cannot for the life of me figure out what's going wrong.
All I'm trying to do is load this:
https://recruit.zoho.com/ats/EmbedResult.hr?jodigest=2cV.Sr2As6VxhLMxQGuTNij*g.Fb3J7ysduDs.AC9sU-&atslocale=en_GB&rawdata=json
which I believe is json, into either javascript/jquery or php and use the data.
I've looked into jsonp, followed some tutorials, used some demos as templates and just can't get the above data to work.
If anyone can shed some light it would be much appreciated. It really shouldn't be this complicated, but I don't know what's going wrong.
Yep, that's JSON. The site may not support JSONP, so you're gonna have to use PHP to do this.
This is untested, but should work.
<?php
$url = 'https://recruit.zoho.com/ats/EmbedResult.hr?jodigest=2cV.Sr2As6VxhLMxQGuTNij*g.Fb3J7ysduDs.AC9sU-&atslocale=en_GB&rawdata=json';
$JSON = file_get_contents($url);
// echo the JSON (you can echo this to JavaScript to use it there)
echo $JSON;
// You can decode it to process it in PHP
$data = json_decode($JSON);
var_dump($data);
?>
JSONP relies on the server to return a JSONP formatted response. Basically, to use JSONP the server needs to return a JSON string wrapped in a function invocation ({"foo":1} becomes func({"foo":1})).
As the server your using doesn't return a JSONP response, you cannot use JSONP, you can only use JSON.
This is a shame, as JSON cannot be used x-domain due to the same origin policy (SOP). Therefore, the only option you have is to use a proxy server, which retrieves the JSON from the server, and either gives it to you in JSONP (see Yahoo Pipes), or which is on the same domain as the requested page (write a simple PHP script to get the file using file_get_contents() and then echo the output), in which case it can return the JSON.
I breifly looked at the requirements and it looks like you need an API key as well as an account. I saw that the site provides services for XML and JSON only. It looks to be fairly well documented.
I want to request this URL translate.google.com/translate_a/t?client=t&text=hello&hl=en&sl=en&tl=ar&multires=1&oc=3&prev=btn&ssel=0&tsel=0&sc=1
using PHP and reading the response. How ?
There are a number of options with cURL and readfile being the obvious ones.
You can use the file_get_contents() see http://php.net/manual/en/function.file-get-contents.php
But it is not as efficient as other methods to read remote files.
ie)
$mytranslation = file_get_contents("translate.google.com/translate_a/t?client=t&text=hello&hl=en&sl=en&tl=ar&multires=1&oc=3&prev=btn&ssel=0&tsel=0&sc=1");
Use the Google Translate API instead of requesting an HTML page and parsing the HTML.
Sample:
GET https://www.googleapis.com/language/translate/v2?key=YOUR-API-KEY&source=en&target=de&q=Your%20text