user1170117
user1170117

Reputation: 153

Pass php results to another website.

So what I am trying to do is this:

On my server users can put there YouTube channel name. My php file will then parse the channel and output HTML code with results. What I am looking to do is for the users to be able to put a code on there website that till call on my website lets say youtubevideos.com/videos.php?channel=channelname my code will take that name and output the videos back to there site. much like Google ads I guess.

Any idea how that is done, other than an iframe, I figured that will be my last resort.

I think what I'm looking for if for them to put a JavaScript on there site that will render as the HTML code I'm pushing from my php file.

Thank you!

Upvotes: 0

Views: 137

Answers (2)

Gunjan Karun
Gunjan Karun

Reputation: 795

There would be two parts of this solution.

In the videos.php file on your server, you would implement the logic to scrape the data from the original site and format it in the way you want to show on the final website.

For the end user, you would give a code similar to this that they would have to paste in their php pages to display the content from your site.

$your_website_url="http://youtubevideos.com/videos.php?channel=channelname";
//Don't forget the http:// at the start.

echo file_get_contents($your_website_url);

If file_get_contents() gives a security error, you can use .

I hope that helps.

Upvotes: 1

Mr_DeLeTeD
Mr_DeLeTeD

Reputation: 846

The receiver code which is on the server you target need to set a header like that :

"Access-Control-Allow-Origin:*"

So, if you provide a service which need to exchange with your server & your code, is it possible. If you can't edit the targeted code & the header is not setted, it'll be impossible

Upvotes: 1

Related Questions