Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Help required using PHP and Twitpic API

  • 09-04-2009 8:42am
    #1
    Registered Users, Registered Users 2 Posts: 2,458 ✭✭✭


    Can someone point me in the direction for help regarding my problem.
    I am trying to use the twitpic.com API to write an app that will allow me to upload photos to twitpic.

    So far i have created a simple form that uses the users twitter username and passwd and a browse field to get the photo file. This is the easy part and it uploads the file and the photo is then visible on twitpic.

    The problem is that then this just displays an XML response.
    <rsp stat="ok">
       <mediaid>31gls</mediaid>
       <mediaurl>http://twitpic.com/31gls</mediaurl>
    </rsp>
    

    how do I get PHP to grab this, parse it etc.? :confused:
    EDIT: I can get the parsing bit sorted myself, just cannot grab the XML to parse it in the first place

    Anyone have any good websites with help for this??

    Thanks.
    Tagged:


Comments

  • Registered Users, Registered Users 2 Posts: 6,602 ✭✭✭daymobrew


    Please post the code you have or describe the algorithm you are using.


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Yeah a bit of code would help.

    I'm guessing you created a regular HTML form and send a POST to an address and get back the xml in your browser.

    Check up the cURL library in PHP, this will make posting data easy.


  • Registered Users, Registered Users 2 Posts: 2,458 ✭✭✭dmeehan


    Webmonkey wrote: »
    Yeah a bit of code would help.

    I'm guessing you created a regular HTML form and send a POST to an address and get back the xml in your browser.

    Check up the cURL library in PHP, this will make posting data easy.

    all i have is as you say a regular HTML form and send a POST and get back the XML. i will have a google for cURL as I dont know what it is even.

    any good websites along the lines of "cURL for dummies" ??
    :-)


  • Registered Users, Registered Users 2 Posts: 8,070 ✭✭✭Placebo


    using it for my clickatell script

    [PHP]

    $url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id";

    // do auth call

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_exec($ch);
    $ret = curl_exec($ch);
    curl_close($ch);


    //so your XML will be stored in $ret, then i suppose you can use substring or stristri or whatever to parse it
    [/PHP]


  • Registered Users, Registered Users 2 Posts: 2,458 ✭✭✭dmeehan


    thanks for the replies, but it looks like I will have to uplaod the file to a temp folder on the server and then cURL it to twitpic

    back to the drawing board


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,045 ✭✭✭Bluefrog


    The issue with that from a usability point of view is that you will be essentially uploading the file twice - first to your own server and then on to twitpic using Curl. Worst case scenario is that your user has to wait twice as long to learn that the file got delivered ok.

    You want to cut yourself out as the middleman so the file goes directly from the user to twitpic and intercept their response. You could do this using a java applet or Flash but then you have the security issues of gaining local file access.

    Another approach off the top of my head might be to host the upload form with its action set to twitpic on your own server in an iframe and hide that iframe when the upload button is clicked. You can then monitor the content of the hidden iframe to check that you get back a successful response and if not, alert the user.


  • Registered Users, Registered Users 2 Posts: 2,458 ✭✭✭dmeehan


    i think i will just leave it for now - havent got the time to be digging in to cURL etc.
    thanks anyways


Advertisement