Support » Everything else WordPress » cURL request to plugin repository fails 403

  • Resolved 123host


    I am trying to update a file in my plugin by getting the original contents from the wordpress repository via cURL

    The URL is of the format – visiting the URL in a browser shows the code, exactly what I am after.

    However, the cURL response is

    <head><title>403 Forbidden</title></head>
    <center><h1>403 Forbidden</h1></center>

    It appears grabbing source code this way isn’t allowed. file_get_contents() doesn’t work either.

    Is there a way to do this that works?

Viewing 2 replies - 1 through 2 (of 2 total)
  • threadi


    I have just tested this. A curl on the console works without any problems. However, it only works via PHP if you set the UserAgent to a browser. So with such a specification in the code:

    $ua = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13';
    curl_setopt( $cd, CURLOPT_USERAGENT, $ua);

    If this still doesn’t work for you, please show the code you used to see where the difference is.

    Thread Starter 123host


    YES! Thanks so much, that worked.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.