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
Related
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);
I am trying to implement an store locator using php and mysql and google maps
I have gone through this article "https://developers.google.com/maps/articles/phpsqlajax_v3 "
it says "Check your configuration or try initializing a domxml_new_doc() to determine if your server's PHP has dom_xml functionality on."
But apparantly mine is not on because it is giving me this error :
"Fatal error: Call to undefined function domxml_new_doc() in C:\wamp\www\StoreLocator\phpsqlajax_genxml.php on line 5"
I am using php 5, and I am not sure how I can turn it on.
Please help me with your opinions.
This question might help answer your problems.
Are you sure you want to go down the XML route and not the JSON one?
I have a GTFS protocol buffer message (VehiclePosition.pb), and the corresponding protocol format (gtfs-realtime.proto), I would like to read the message in PHP alone (is that even possible?).
I looked at Google's python tutorial https://developers.google.com/protocol-buffers/docs/pythontutorial and encoding documentation https://developers.google.com/protocol-buffers/docs/encoding and https://github.com/maxious/ACTBus-ui/tree/master/lib/Protobuf-PHP, but I am having a really hard time conceptualizing what is going on. I think I understand that gtfs-realtime.php is a compiled instruction set of the encoding defined in gtfs-realtime.proto (please correct me if I am wrong), but I have no clue how to get it to decode VehiclePosition.pb. Also, what are the dependencies of gtfs-realtime.php (or the python equivalent for that matter)? Is there anything else I have to compile myself or anything that is not a simple php script if all I want to do is read VehiclePosition.pb?
Thanks.
edmonscommerce and Julian are on the right track.
However, I've gone down the same path and I've found that the PHP implementation of Protocol Buffers is cumbersome (especially in the case of NYCT's MTA feed).
Alternative Method (Command Line + JSON):
If you're comfortable with command line tools and JSON, I wrote a standalone tool that converts GTFS-realtime into simple JSON: https://github.com/harrytruong/gtfs_realtime_json
Just download (no install), and run: gtfs_realtime_json <feed_url>
Here's a sample JSON output.
To use this in PHP, just put gtfs_realtime_json in the same directory as your scripts, and run the following:
<?php
$json = exec('./gtfs_realtime_json "http://developer.mbta.com/lib/GTRTFS/Alerts/VehiclePositions.pb"');
$feed = json_decode($json, TRUE);
var_dump($feed);
You can use the official tool: https://developers.google.com/transit/gtfs-realtime/code-samples#php
It was released very recently. I've been using it for a few days and works like a charm.
I would assume something along the lines of this snippet:
<?php
require_once 'DrSlump\Protobuf.php';
use DrSlump\Protobuf;
$data = file_get_contents('data.pb');
$person = new Tutorial\Person($data);
echo $person->getName();
as taken from the man page: http://drslump.github.io/Protobuf-PHP/protobuf-php.3.html
Before that step, I think you need to generate your PHP classes using the CLI tool as described here: http://drslump.github.io/Protobuf-PHP/protoc-gen-php.1.html
so something along the lines of:
protoc-gen-php gtfs-realtime.proto
Sorry Harry Truong, I tried your executable but it returns always NULL.
What I am doing wrong?
Edit: The problem is that I have no permission to execute in my server. Thanks for your executable.
I am trying to use decodeURIComponent in a JS function inside Facebook instead of using urldecode in PHP. But I keep getting the following error :
Error: a194182563946198_decodeURIComponent is not defined
Can anyone kindly help ?
Thanks.
-
Ahsan
On a second thought, I am using a PHP intermediate file that does the work on ajax call. :)
-
ahsan
In my project, I'm using HTML_ToPDF PHP class, which uses html2ps script to convert from HTML to PDF file.
Recently I upgraded my production server to Debian 5 (Lenny) and, after that, HTML_ToPDF is no longer working:
convert() method from HTML_ToPDF class is returning this error:
Error: there was a problem running the html2ps command. Error code returned: 127. setDebug() for more information.
And, the output from html2ps call is:
/usr/bin/perl: symbol lookup error: /usr/lib/perl5/auto/Compress/Zlib/Zlib.so: undefined symbol: Perl_Tstack_sp_ptr
Any help would be appreciated, thanks!
[Edited]
After some tests, I've found that the problem happens only with HTML containing images ( tags). When html2ps founds the first image it crashes. Converting HTML without images works fine. Any idea? Thanks!
Try this
apt-get install perl=5.8.8-7etch6 perl-base=5.8.8-7etch6 perl-modules=5.8.8-7etch6 debconf-i18n=1.5.11etch2 liblocale-gettext-perl=1.05-1 libtext-iconv-perl=1.4-3 libtext-wrapi18n-perl=0.06-5 libtext-charwidth-perl=0.04-4 html2ps=1.0b5-2 libapache2-mod-perl2=2.0.2-2.4 libcompress-zlib-perl=1.42-2 libfuse-perl=0.07-2+b2 libhtml-parser-perl=3.55-1 libhtml-tree-perl=3.19.01-2 libio-zlib-perl=1.04-1 libwww-perl=5.805-1 perlmagick=7:6.2.4.5.dfsg1-0.14 snmpd=5.2.3-7etch4 xhtml2ps mysql-client=5.0.32-7etch8 mysql-client-5.0=5.0.32-7etch8 libdbd-mysql-perl=3.0008-1 libdbi-perl=1.53-1etch1
http://www.deberias.com
This is an issue with the initial conversion from HTML to PS. Usually due to poorly written HTML.
Can you show some examples of what you are trying to convert?
To be honest I've found wkhtmltopdf to be far better than html2ps, even though it's at a fairly early stage of development.
I wrote a blog about it, but if you don't want to read that basically it uses KHTML/Webkit's rendering engine to render the page which is a bit more sensible than the usual approach of writing a complete HTML renderer.
The distributed binary worked just fine on my Debian server, and frankly the results are excellent.