• I’m currently trying to add objects to a Parse database when i create a new post. Obviously, that makes sense right? Everytime I post a new post a new object is created in the database….well I can’t figure out how to do something that simple…

    The steps i’ve taken so far is altering the post.php per the wordpress documentation. So i inserted this code in the wp_insert_post function:

    $className = "Posts";
    $url = 'https://api.parse.com/1/classes/' . $className;
    $appId = 'myIDNumbers here';
    $restKey = 'myKeyNumbersHere';
    
    $objectData = '{"postTitleString": "POST TITLE GOES HERE"}';
    
    $rest = curl_init();
    curl_setopt($rest,CURLOPT_URL,$url);
    curl_setopt($rest,CURLOPT_PORT,443);
    curl_setopt($rest,CURLOPT_POST,1);
    curl_setopt($rest,CURLOPT_POSTFIELDS,$objectData);
    curl_setopt($rest,CURLOPT_HTTPHEADER,
        array("X-Parse-Application-Id: " . $appId,
            "X-Parse-REST-API-Key: " . $restKey,
            "Content-Type: application/json"));
    
    $response = curl_exec($rest);
    echo $response;

    So far when I inserted it in post.php it automatically updates the database every time the “new post” page loads not when a new post is inserted. My goal is to perform this action and include that new posts title when the publish button is clicked. Any suggestions?

  • The topic ‘Adding Post Titles to Parse.com database’ is closed to new replies.