Apply edits with PHP

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I trying to develop a PHP script that will simply applyedits to a feature services.

Right now I'm trying to use the In the ESRI restend point example. I'm thinking if someone can help me, point me to some doc, show me how to use the esri endpoint. I will be able to take that script learn from it and move from there. There are several moving parts I'm hoping to accomplish but right now I'm stuck on this piece.

If I hit this esri rest endpoint:

sampleserver3.arcgisonline.co...r/0/applyEdits

and add these parameters to the add input box

[{"geometry":{"x":-13085962.2699721,"y":4061306.82523268,"spatialReference":{"wkid":102100}},"attributes":{"description":"Test Nat","type":5}},{"geometry":{"x":-13072136.6421672,"y":4073467.58686212,"spatialReference":{"wkid":102100}},"attributes":{"description":"klsf","type":0}}]

I can add a feature.

I want to create a simple PHP script that will do this for me. CAN someone show how to do this?

If I can get this working I'm hoping I can feed the parameters from an xml feed and consistently push data to my rest points. Thanks.

profilepic.png
manpreet 2 years ago

 

this should do it. Remind that this is not asynchronous.

$adds ='[{"geometry":{"x":-13085962.2699721,"y":4061306.82523268,"spatialReference":{"wkid":102100}},"attributes":{"description":"Test Nat","type":5}},{"geometry":{"x":-13072136.6421672,"y":4073467.58686212,"spatialReference":{"wkid":102100}},"attributes":{"description":"klsf","type":0}}]';


$postdata = http_build_query(
  array(
    'adds' => $adds,
    'updates'=> 'null',
    'deletes'=>'null',
    'f' => 'json'       
    )
);
$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);
$context  = stream_context_create($opts);   
$result = file_get_contents(*YOUR_FS_URL*, false, $context);    
$result2 = json_decode($result,true);/*decode the result as array*/
$result3 = json_decode($result);/*decode the result as object*/

print_r($result2);

0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.