Jump to content
  • 0

Getting Content Of A Page By Curl


Question

Posted

I am doing a wordpress plugin that fetch blesta pages using curl. Did login to blesta.

 

When i try to access content of the below link using curl

domain.com/admin/widget/system_overview/admin_main/

 

i'm getting content of page

domain.com/admin/

not that of

domain.com/admin/widget/system_overview/admin_main/

 

Code is below

 

 $tempurl =  'http://domain.com/admin/widget/system_overview/admin_main/';
 $ch = curl_init();
 curl_setopt($ch,CURLOPT_URL,  $tempurl);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                //curl_setopt($ch, CURLOPT_POST, 1);
                //curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
               // curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
   $buffer = curl_exec($ch);    
   echo $buffer;           
   curl_close($ch);

6 answers to this question

Recommended Posts

  • 0
Posted

The main widget method is only available via AJAX, and redirects back to the base URI otherwise. You would need to pass in the appropriate AJAX headers and content type.

  • 0
Posted
  On 12/18/2013 at 5:49 AM, Module Developer said:

@Tyson

 

Do you think we can show the main widget content in wordpress then? is there any technology for that?

 

 

You could fetch the markup for the system overview widget, but it won't look right outside of Blesta because it will be missing all of the CSS/javascript necessary to render it correctly.

  • 0
Posted

You could try:

curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Requested-With: XMLHttpRequest", "Content-Type: application/json; charset=utf-8"));

I haven't tested it, so you may need to play around with it.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...