I'm trying to get the HTML source code of a SoundCloud link through PHP, but the https protocol makes it nearly impossible with file_get_contents(). I went with curl, but even though it does connect to SoundCloud, it returns a "track not found" error instead of the actual track page, so I suppose there's some additional protection.
Any help getting over this? I know there must be a way, since tools like http://source.domania.net/ have no trouble when I input an URL like https://soundcloud.com/mild-network/wcbf, for example.
Alternatively, is there any "page source viewer" online that can access https and has an API I could work with?
Hope this isn't too specific.
Related
I want to get the m3u8 link which loaded after playing video. From the website https://www.firstonetv.eu. It's unavailable in HTML source code. Now I can see it on network tab in Chrome. Here is the image:
Network tab snap
But I want to get it through PHP.Also, a javascirpt solution is appreciated. How could I get the m3u8 link?
Every site is different. You would have to reverse engineer their site to figure out how it's getting the URL to the HLS playlist.
Alternatively, a generic solution could be implemented by writing a browser extension to look for application/x-mpegURL in the content type headers in HTTP responses... and when you find one, log it or open it elsewhere. Keep in mind that the video you get could be anything... ads and such.
What you should do instead though is contact the site and ask for access to their API or a better proper way to do this. You do have their permission, right?
I'm trying to make a call from PHP to the YouTube API v3 to get the duration of a video. I've got my developer key, and have assembled what seems to be a valid URL, based on Google's docs and many other posts on SO:
https://www.googleapis.com/youtube/v3/videos?id=rpVJkH7dWsY&part=contentDetails&key={myDeveloperKey}
I can enter this url into a browser, and a correct hunk of stuff comes back. But when I call it from PHP via file_get_contents($the_url), it fails with a "Connection timed out" error.
I must be doing something wrong; any advice? Thanks!
I'm doing it the exact same way you're describing, with file_get_contents($the_url), and it works fine for me. The only thing I can think of if it works in a browser but not on your server, is to make sure you're using a different API key that's a server key, where you'd be using a browser key to test from your browser, presumably. If that's not the issue, I can't think of any other obvious reason it shouldn't work.
I'm using Facebook Debugger for the URL's i try to share
https://developers.facebook.com/tools/debug/og/object/
Show existing scrape information gives me Error parsing input URL, no data was cached, or no data was scraped. and when URL is shared, no thumbnail is shown.
However after using Fetch new scrape information I'm getting proper output, and the sharing is working fine.
This is not probably because of cache, because it happens also when appending random suffix to the URL.
How to fix the damn thing? Situation is weird, as the URL's title and description is parsed fine.
Facebook doesn't scrape information from your website each any every time you share a link. Facebook saves a cached copy of the information on the Facebook servers.
When you click "Fetch new scrape information" it forces Facebook to ignore the cached information and scrape your website immediately.
It sounds like you (or somebody) may have tried to share your URL on Facebook earlier, which has returned an error. Facebook remembered this error until you forced it to fetch new information.
It's perfectly normal so I wouldn't worry about it. Facebook would have refreshed it's cache of your page sooner or later and fixed it.
So a while back I used to use the twitter json search in one of my apps but it seems since the change in API versions there has been some major changes which even after reading the documentation I still can't get my head around and it really doesn't make it very easy to understand so hopefully one of you tech guys out there can help me out.
I want to clean my application up so it works again in plainly doing the following:-
http://search.twitter.com/search.json?
q='+param+'&
rpp=100&
result_type=recent&
lang=en
Obviously with the changes this is no longer possible but I want to be able to do this again using the new address but in JQuery unless someone can suggest either a tutorial or a piece of code or even a link to a topic where I could get my answer. I'm also open to using PHP as this is what I used at one point with searching Facebook's timeline and you can get an access token using $.get() for Facebook so surely it would be the same with Twitter too?
Any advice/code is welcome.
Thanks!
the search API needs authorization now. I'd say that, first off, you need to call the https url not http.
With Abhramam William's library you'd do something like the following, after having received your app's bearer token:
$your_tweets = $connection->get("https://api.twitter.com/1.1/search/tweets.json?q=from:grey_mina&result_type=recent&count=5");
I have been told to work out a means of calculating whether a user has accessed a website from scanning a QR code or by accessing through normal methods. The company are using Google Analytics. Ideally the system would calculate what country the user is in when the QR code was scanned, although I think Google analytics does most of this for me.
My initial idea was to have a blank redirect page in the middle of the QR code and the full site, and put some separate analytics code in to that. Alternatively I could perhaps throw in a PHP referrer script that alters the analytics code based on the response, but this would still require a landing redirect page.
I'm a bit of a newbie, and this is quite a big client, so I thought I'd ask on here before starting anything that might not be the best method!
That’s one good option. Another would be to use a query string parameter in the URL, like this:
http://example.com/page/?from=qrcode
If you have control over the QR codes, you can add a GET variable to the URL, and then in your index page, you merely test for the QR-code GET variable and {do magic} if it is set or has a certain value.
I would use an intermediate page, as it gives you one point of entry for all QR encoded URLs.
From the QR code:
http://yoursite.com/qr.php?url=http%3A%2F%2Fyoursite.com%2Ffoo.php
Anywhere else:
http://yoursite.com/foo.php
Then on qr.php, you would simply use a header() redirect to $_GET['url'] after you're done with whatever statistics you're going to record or analyze.
Well if you can change the QR code:
-change the info to something like www.client-site.com\landing.php?referer=qr
You can check then in your landing.php
If you can't (then it is messy):
-when accessing through QR code then the HTTP_REFERER is empty and the client is using a phone with a certain browser, you can use this info to determine if he is using a phone and accessed the page directly (90% of cases people use Google before goint directly to a site- in this case you have a HTTP_REFERER)
Hope this helps...
I would build your URL for the QR code using Google's Analytics URL builder.
That way, you don't have to create custom filters are anything. Also, if you ever create new QR codes in the future on any other marketing material, you can track which marketing concept worked easily, rather than just saying that it was just a QR code that brought them to the site. Good luck.